Wrapping a C library in Python
Jean Brouwers
mrjean1ATcomcastDOTnet at no.spam.net
Thu Nov 18 20:22:22 EST 2004
Take a close look at Pyrex at
<http://nz.cosc.canterbury.ac.nz/~greg/python/Pyrex/>
/Jean Brouwers
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
> dictionary.
>
> 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
mailing list