Bridging Python and C

Philip Semanchuk philip at semanchuk.com
Thu Jul 23 17:54:33 EDT 2009


On Jul 23, 2009, at 5:45 PM, Mohan Parthasarathy wrote:

> Hi,
> I am a newbie. It looks like there are quite a few ways to bridge  
> Python and
> C. I have a bunch of C code and I just need Python wrappers for it.  
> If i
> google for this I get SWIG, Boost etc. And I also see
>
> http://www.python.org/doc/2.5.2/ext/intro.html
>
> What is the recommended way for doing this ?

"Recommended" depends on what you want to accomplish. SWIG, Boost,  
etc. all have pros and cons.

One option you didn't mention is ctypes which is part of the Python  
standard library. It allows you to pass params to C functions. Works  
great for me!


HTH
Philip




More information about the Python-list mailing list