[SciPy-dev] Inclusion of cython code in scipy

Francesc Altet faltet@carabos....
Thu Apr 24 11:25:00 CDT 2008

A Thursday 24 April 2008, Brian Granger escrigué:
> > Then why not start a project to get SWIG to do away with the shadow
> > module?
> I don't have a passion for actually working seriously on these
> projects - I am lazy and simply want to use them :)
> >  Lets take a simple case of someone wanting to handle a growing
> >  collection of say a million particles and do something to them. 
> > How do you do that in cython/pyrex and get the performance of C and
> > interface to numpy?  Worse, even if it were possible, you'll still
> > need to know something about allocating memory in C and
> > manipulating pointers.  I can do that with C++ and SWIG today.
> C++ STL containers are truly great for things like this.  I would
> write a simple c++ header file that defines the Particle class,
> create an std::vector<Particle> to hold them and wrap the whole thing
> into Cython.  I have already done stuff like this (templated c++ with
> STL) with cython and it works great.  Furthermore, you end up with an
> actual C/Python extension type that 1) is super fast 2) has its own C
> api that can be called from other C extensions.
> Sure SWIG can do this too.  If you don't mind the extra pure python
> layer that SWIG has, then it is really a matter of personal
> preference and experience.  But, if performance is really important
> and you don't want the extra python layer, SWIG doesn't cut it.  The
> one place where Cython does not do well with C++ code currently is if
> you have a very large C++ API (100s of classes).  Then SWIG is the
> way to go.

Can you develop a bit more in detail why Cython should not be adequate 
for wrapping 100s of C++ classes?  Just curious.


>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data

More information about the Scipy-dev mailing list