How to call and execute C code in Python?

Devin Jeanpierre jeanpierreda at gmail.com
Sun May 13 19:19:56 EDT 2012


On Sun, May 13, 2012 at 11:58 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> David Shi, 13.05.2012 15:25:
>> Can anyone tell me how to call and exectute C code in Python?
>
> Take a look at Cython, a Python-like language that supports native calls to
> and from C/C++ code. It translates your code into very efficient C code, so
> the wrapping code tends to be very fast (often faster than hand written C
> code).

More than just speed -- it's, IME, way easier to use and debug than
ctypes (thanks to having incredible gdb support and compiler warnings).

I swear, this is black magic:

http://docs.cython.org/src/userguide/debugging.html

Now if only my editor would bold those "cdef"s... :)

-- Devin



More information about the Python-list mailing list