wrapping C functions in python

Ivan Illarionov ivan.illarionov at gmail.com
Thu Apr 10 12:30:28 EDT 2008


On Apr 10, 9:57 am, Paul Anton Letnes <paul.anton.let... at gmail.com>
wrote:
[...]
>   , but as I mentioned, it seems to be a bit complicated to wrap heavy
> data structures like arrays.

Hello,

I suggest that you might take a look at how other people solved the
same problems. The great example is path.c inside PIL [1].
`PyPath_Flatten` function creates C array from Python data,
`path_to_list` converts C array into Python list and `path_map`
applies a Python function to C array.

Also take a look at Python buffer interface [2] - use array module on
Python side instead of lists and you'll have almost instant C arrays
from Python data and vice versa.

1: http://effbot.org/downloads/Imaging-1.1.6.tar.gz
2: http://docs.python.org/api/buffer-structs.html

Regards,

--
Ivan



More information about the Python-list mailing list