[SciPy-dev] Inclusion of cython code in scipy
Prabhu Ramachandran
prabhu at aero.iitb.ac.in
Thu Apr 24 00:27:18 EDT 2008
Brian Granger wrote:
> The big difference though between cython and swig is that the top
> level layer in swig is slow pure python code. In cython, you get fast
> C/python extension types that can be called from other C/C++ extension
> code without going through a slow python layer. That is a huge
> difference.
Then why not start a project to get SWIG to do away with the shadow module?
The biggest problem IMHO with pyrex (and perhaps cython, which I've only
glanced at) is that it isn't straight C or C++ and neither is it pure
Python and you are unsure what the right incantation is that is supposed
to work most efficiently.
From what I've seen, most people seem to like to interface
straightforward code with the lower level tools like pyrex and cython.
I've never seen (please show me an example I can look at) a more complex
case where you have complicated data structures (say a large mutable
container) rather than simple elementary data types that you need to
manipulate. If you need to do this, you always need to go back to the
traditional low level languages like C or C++ which SWIG wraps out of
the box for the most part.
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.
cheers,
prabhu
More information about the SciPy-Dev
mailing list