[SciPy-dev] Inclusion of cython code in scipy

Stéfan van der Walt stefan at sun.ac.za
Wed Apr 23 04:02:27 EDT 2008


2008/4/23 Nathan Bell <wnbell at gmail.com>:
>  Writing a substantial amount of code in a special-purpose language
>  like Cython is always risky.  Will Cython exist in 5,10,15 years?

The idea is, of course, that Cython should ultimately *not* be a
special-purpose language, but as close to Python as possible.  That is
also why we rely on those two GSOC projects, which try to eliminate
the ndarray indexing differences between Python and Cython.  That way,
in 10 years you'll still have Python code, even if cython doesn't
exist any more.  Hopefully, by then, PyPy or some such project would
have capitalised on VM developments to such extent that your Python
code runs as fast as the current C code (look at what the jruby guys
have accomplished, for example).

Your SWIG wrappers are easy to read, but that is not the case for some
other parts of NumPy and SciPy, though, so I buy Matthew's argument:
to increase the number of eyes on our code, we should improve
readability.  For example, I could see that implementing lil_matrix in
Cython would make sense, given that it runs for loops over Python
lists.  Also, a great number of bugs in NumPy originate from reference
counting errors, which are notoriously hard to catch; Cython helps
skirt those issues.

To be clear, I'm all for leaving sparsetools alone (it works).  For
implementing new code in SciPy -- especially sections that interface
heavily with Python -- I'd use Cython, though.

Cheers
Stéfan



More information about the SciPy-Dev mailing list