Calling cpp from python/SWIG
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Mar 13 03:18:00 EDT 2007
En Tue, 13 Mar 2007 03:33:43 -0300, Frank <supervau at gmail.com> escribió:
> I want to parse an array M1 from python to a cpp function fct which
> returns an array M2.
>
> How can I do this best? Is SWIG appropriate or is there something
> else?
If you're going to call a single function, declare it with extern "C" (or
write a wrapper function) and use ctypes from Python.
Try to keep the memory allocation in Python: instead of returning another
array, make the function use the *same* input array, or give it -from
Python- a previously allocated array.
ctypes comes with Python 2.5, and you can download and install it for
previous versions too.
--
Gabriel Genellina
More information about the Python-list
mailing list