[SciPy-dev] Inclusion of cython code in scipy

Nathan Bell wnbell@gmail....
Wed Apr 23 09:41:06 CDT 2008

On Wed, Apr 23, 2008 at 8:00 AM, Ondrej Certik <ondrej@certik.cz> wrote:
>  Isn't this a similar (if not the same) problem when writing your code
>  using SWIG?

No, because the implementation (i.e. part that's harder to recreate)
is still written in C++.

>  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.

A lot?  I took numpy.i from the NumPy repository, made a few changes,
and added sparsetools.i to generate the templates.  If SWIG
disappeared overnight, I'd wrap *the very same, unmodified C++ code*
using another wrapper generator (perhaps Cython).  If I wanted to use
sparsetools in another VHLL then I would wrap it for that one too.

OTOH if I had written sparsetools in Cython (as opposed to wrapping
sparsetools with Cython) and Cython disappeared, then I'd have to
rewrite the a substantial amount of the implementation.

Again, I think using Cython in place of SWIG is a fine thing to do.  I
just wouldn't want write too much of it any more than I'd want to
write reams of hand-coded C wrappers or reams of SWIG.

>  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.

I don't disagree.  However, writing C++ and wrapping with SWIG is also
easier than writing hand-coded extension modules, with the added
benefit of decoupling the core implementation from the interface.

Nathan Bell wnbell@gmail.com

More information about the Scipy-dev mailing list