Wrapping a C library in Python
mrjean1ATcomcastDOTnet at no.spam.net
Fri Nov 19 02:22:22 CET 2004
Take a close look at Pyrex at
ProphICy Semiconductor, Inc.
In article <roy-99F088.20103518112004 at reader1.panix.com>, Roy Smith
<roy at panix.com> wrote:
> I've got a C library with about 50 calls in it that I want to wrap in
> Python. I know I could use some tool like SWIG, but that will give me a
> too-literal translation; I want to make some modifications along the way
> to make the interface more Pythonic.
> For example, all of these functions return an error code (typically just
> errno passed along, but not always). They all accept as one of their
> arguments a pointer to someplace to store their result. I want to
> change all that to returning the result directly and throwing exceptions.
> I also want to mutate some of the return types. A common way these
> functions return a set of values is a pair of arrays of strings, forming
> key-value pairs. In Python, it would make sense to return this as a
> I know what I'm describing is kind of vague, but are there tools around
> which might help automate (at least in part) this translation process?
More information about the Python-list