Accessing c objects in python

Thomas Heller theller at python.net
Fri Aug 8 09:23:04 EDT 2003


Alex Martelli <aleax at aleax.it> writes:

> Dave Kuhlman wrote:
>    ...
> [snipped: C API usage directions]
>
>> Is there an easier way?  I'm not sure, but I'd certainly read the
>> following section of the Pyrex documentation.  It's about how to
>> wrap C structures:
>> 
>>     http://ldots.org/pyrex-guide/3-structures.html
>    ...
>> Any Pyrex experts listening in?  Am I on the right track here?
>
> I'm no pyrex expert, but I recently re-evaluated various options
> for wrapping large existing C libraries: C API, Boost Python,
> Pyste, pyrex, ctypes, and Swig.  Somewhat to my surprise (I had
> bad memories about it from the past...), Swig came up on top in
> terms of simplicity.  Pyste might easily be best for _C++_
> libraries, already organized into classes and possibly using
> templates &c -- it, in turn, "rests" om Boost Python.  Boost
> itself -- or pyrex if you'd rather not use C++ for the purpose --
> might likely be best if you want to code some significant amount
> of fast logic, not just wrappers.  But for "just wrappers", and
> C libraries as opposed to C++ ones, Swig rules.
>
> I'd use the C API directly only if the other tools were ruled
> out for some reason (e.g., licensing); it's by far the largest
> amount of work -- all other tools rest on top of it and can be
> seen as "code generators" for it that save you aggravation.

Would you care to write a more detailed summary of your findings? This
would probably make a good page in the main Python wiki...

Thomas




More information about the Python-list mailing list