Wrapping C with Python
RPM1
rpm9deleteme at earthlink.net
Mon Aug 4 07:34:19 EDT 2008
Anish Chapagain wrote:
> Hi!!
> I tried wrapping a simple C code suing SWIG to Python, but am having
> problem,
I am not too familiar with SWIG, (I have looked at it), but you may want
to try ctypes in the standard module library. It's very easy to use. I
use it on Windows with gcc but I believe it works fine on Linux too.
Basically you just compile your C code as a regular C code dll. ctypes
then allows you to access the functions in the dll very easily. I was
concerned that performance might be an issue but that has turned out not
to be true. I'm writing a chess program and the C dll handles the move
generation so it is getting called a lot. So far it runs at about
200,000 calls per second.
Patrick
More information about the Python-list
mailing list