[SciPy-dev] Inclusion of cython code in scipy

Neal Becker ndbecker2@gmail....
Thu Apr 24 10:59:30 CDT 2008


Brian Granger wrote:

>> 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.
> 
Could you point me to a simple example of this, please?



More information about the Scipy-dev mailing list