How to call and execute C code in Python?
Stefan Behnel
stefan_ml at behnel.de
Sun May 13 11:58:32 EDT 2012
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).
http://cython.org/
Here are a couple of examples:
http://docs.cython.org/src/tutorial/external.html
There's also the "ctypes" package in the standard library, which is usable
for simple wrapping cases that are not performance critical.
Stefan
More information about the Python-list
mailing list