[SciPy-dev] Inclusion of cython code in scipy
Thu Apr 24 11:19:01 CDT 2008
On Thu, Apr 24, 2008 at 9:59 AM, Neal Becker <firstname.lastname@example.org> wrote:
> 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.
Unfortunately, the context I have done this in is proprietary code for
my employer. But, I will try to put together a simple example this
weekend and post it to launchpad. The documentation on these
capabilities of Cython isn't great right now for sure, so some example
code would sure help.
More information about the Scipy-dev