[Numpy-discussion] swig numpy2carray converters

Sebastian Haase haase@msg.ucsf....
Fri Nov 30 04:55:36 CST 2007


On Nov 30, 2007 5:16 AM, Bill Spotz <wfspotz@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.
>
Hi,
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 ?

Thanks,
Sebastian Haase


More information about the Numpy-discussion mailing list