[Networkit] Solving the copy vs. swap problem in Cython

Christian Staudt christian.staudt at kit.edu
Mon Sep 1 11:31:28 CEST 2014

Hi Michael,

Am 27.08.2014 um 18:19 schrieb Michael Hamann <michael.hamann at kit.edu>:

> Now after adding the missing "except +" statements, setThis() can be defined as 
> follows:
> 	cdef setThis(self,  _Partition& other):
> 		swap[_Partition](self._this,  other)
> 		return self
> where swap is defined as
> cdef extern from "<algorithm>" namespace "std":
> 	void swap[T](T &a,  T &b)
> According to my experiments [0], the partition is not copied anymore.
> I've just pushed the changes to the Dev branch.
> I guess the same could be done for Graph and Cover which means that we 
> wouldn't need to use these "dereference" calls and we wouldn't need the 
> extra code for Cython anymore.

 So special code like this

	/** only to be used by cython - this eliminates an unnecessary copy */
	Graph* _read(const std::string& path) {
		return new Graph{std::move(read(path))};

would no longer be necessary? I am very much in favor of eliminating this kind of code, because it is complicated to explain.
It’s also nicer to have all the Cython-related stuff in the .pyx file.

Michael, will you apply the appropriate changes to the Dev branch?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20140901/c29fdf9d/attachment.sig>

More information about the NetworKit mailing list