[SciPy-dev] Inclusion of cython code in scipy

Ondrej Certik ondrej at certik.cz
Wed Apr 23 09:00:53 EDT 2008


On Wed, Apr 23, 2008 at 8:17 AM, Nathan Bell <wnbell at gmail.com> wrote:
> On Tue, Apr 22, 2008 at 6:19 PM, Anne Archibald
>  <peridot.faceted at gmail.com> wrote:
>  >
>
> >  What do people think about including cython code in scipy?
>  >
>
>  Writing a substantial amount of code in a special-purpose language
>  like Cython is always risky.  Will Cython exist in 5,10,15 years?
>
>  I have little doubt that in 10 years I'll still be able to compile the
>  C/C++ codes I develop today.  Furthermore, if Cython/SWIG/SciPy/NumPy
>  disappeared overnight I'd still have a decent library to work with.
>  IMO using Cython for one-off application or wrappers is fine, but
>  large-scale Cython implementation is probably a bad long-term
>  approach.

Isn't this a similar (if not the same) problem when writing your code
using SWIG?

Let's take sparsetools.i as an example, it also contains a lot of non
python, non C code. So one needs to depend (and maintain!) SWIG. Well,
Cython is a lot more lightweight and more robust solution imho.

Of course it'd be great if the Cython code would also be a regular
Python code, but that will still take some time. But they seem to like
it, for example when I first learned about Cython, I told Robert and
William -- why to use this ugly "for i from 1 <= i < dim:", why not to
use the python way
"for i in range(1, dim):"? And Robert has implemented this in less than a month.

The next step could be to generate Cython code from regular Python
code with annotations in comments or strings imho.

But even if Cython stays as yet another language -- it's still easier
and less error prone than to write the C code by hand.

Ondrej



More information about the SciPy-Dev mailing list