[capi-sig] Problem with reference

Stefan Behnel python_capi at behnel.de
Tue Mar 3 15:44:35 CET 2009

Gustavo Carneiro wrote:
> And Cython *is* a wrapper generator.

Well, no, but PyBindGen is, now that you mention it. It looks a bit like a
FFI (like ctypes), but it generates the corresponding wrapper code, if I'm
not mistaken. Using it for anything but wrapping C/C++ code to make it
callable in Python would be futile.

Cython is (literally) not a wrapper generator as it will not generate a
wrapper for you. You have to write it yourself. Cython is a programming
language to write extension modules for CPython, as generic as that. It
focuses on Python-like simplicity, C-like speed and easy interfacing with
both CPython and C (while better C++ and Fortran support is still being
fledged out). It is being used to write wrappers, but it is also being
used to write high-performance computational code, with or without
interfacing to external C libraries. In the second line, it's also heading
to become a fully-compliant Python compiler (a 1.0 goal), but that doesn't
belong here (just like the automatic-compile-on-import support for Python
files *wink*).

> I clearly remember seeing (ugly) C
> code generated by Cython, before I decided to write PyBindGen.

Let's not start a discussion about taste here. Readable, commented, easy
to debug C code is an obvious goal of the Cython project, simply because
its developers are those who debug it most of the time. That said, we
generally tell our users to look at the highlighted HTML page that Cython
generates of their source code, so that they can focus more easily on
those parts of the generated C code that are worth optimising. Having to
read the entire C code file just to see where things go wrong is not a
good idea.


More information about the capi-sig mailing list