[Cython] new FFI library for Python

Saravanan Shanmugham sarvilive at gmail.com
Mon Sep 17 09:01:44 CEST 2012


I have been using CFFI for wrapping a whole bunch of C libraries and I can
tell you its way easier than Cython.

And a couple of clarifications of misconceptions mentioned on this list.
    1. It does not "require" GCC at run time. The extension can be compiled
at package/install time using the GCC and can run without need GCC at run
time.
    2. Its way easier to wrap C libraries than Cython. I would know, since
I started with Cython. And after many email back and forth with the
cython-users mailing list, I was referred to CFFI which turned out great.
The trouble was wrapping C structures and datastructures with Python
wrappers.
   3. I had to just copy over the C header files as is and had a replace a
few #define values with "..." to ask it to automatically get these values
during compile time from the compiler.  This makes it even more simpler.


Now, I am still a Cython lover when it comes optimizing portions of my
Python code and having it compiled to C.

The question I had in mind is, If I had say a shared math library
libmath.so and wrapped it with a CFFI based python wrapper, which includes
a portion of python wrapper code that calls into the generated Python/C
wrapper shared library.
And then wrote a piece of cython code that invoked that CFFI based python
wrapper, how will my performance be compared to
writing the python wrapper for libmath.so with  cython cdef or cpdef
wrapper function definitions.

Thanks,
Sarvi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20120917/ab1767ec/attachment.html>


More information about the cython-devel mailing list