wrapping C functions in python
Diez B. Roggisch
deets at nospam.web.de
Wed Apr 9 22:30:11 CEST 2008
>> I am a "scientific" user of Python, and hence have to write some performance
>> critical algorithms. Right now, I am learning Python, so this is a "newbie"
>> I would like to wrap some heavy C functions inside Python, specifically a
>> wavelet transform. I am beginning to become aquainted with the functions
>> PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to figure out
>> how to pass Python list -> C function or C array -> return value in Python.
>> I manage to build and run the C function, print to screen, pass string as
>> argument, return an int, etc. The thing which is missing is the magic
For pure C, I would rather recommend ctypes (standard lib since
python2.5), or pyrex. These ease the process of wrapping C tremendously!
More information about the Python-list