[Numpy-discussion] swig numpy2carray converters

Sebastian Haase haase at msg.ucsf.edu
Fri Nov 30 05:55:36 EST 2007

On Nov 30, 2007 5:16 AM, Bill Spotz <wfspotz at sandia.gov> wrote:
> I have just committed the latest version of numpy.i (a swig interface
> file for bridging between C arrays and numerical python) to the numpy
> svn repository.  There are three relatively new features that are now
> supported:
> * It is now possible to wrap functions that expect integer arguments
> and have swig
>   generate wrappers that allow you to provide numpy array scalars.
> * A new ARGOUTVIEW suite of typemaps is provided that allows your
> wrapped function
>   to provide a pointer to internal data and that returns a numpy
> array encapsulating
>   it.  This is potentially dangerous, but necessary in some
> situations for very
>   large data buffers.
This sounds great !!
Could you elaborate on what you mean by "potentially dangerous" !?
Is it important *how* the internal data memory was allocated ? Using
"new" or using "malloc" ?
This would require (following the standard) that the correct, i.e.
corresponding, delete[] or free()  [respectively], de-allocation
function is called.

When is the memory being freed ?
Is (or can !) python taking ownership of the memory and calls the
correct "free"/"delete[]"  function ?

Sebastian Haase

More information about the NumPy-Discussion mailing list