[Numpy-discussion] Wrapping C array
Carlos Pita
carlosjosepita at yahoo.com.ar
Wed May 18 09:56:16 EDT 2005
> > The documentation for PyArray_FromDimsAndData
> > that I quoted in my previous post seems to suggest
> > that a copy is done. But browsing the web
>
> I'd appreciate it if you could send me a reference to where that is
> because it is stale.
I take the excerpt from the numarray user manual from
the python2.3-numarray 1.1.1 debian (sarge) package.
But it's updated in the cvs:
\begin{cfuncdesc}{PyObject*}{PyArray_FromDimsAndData}{int nd, int *dims, int type, char *data}
This function will allocate a numarray of the specified shape and type
which will refer to the data buffer specified by \var{data}. The contents
of \var{data} will not be copied nor will \var{data} be deallocated upon
the deletion of the array.
\end{cfuncdesc}
It seems to be ok. When it says "nor will \var{data} be deallocated upon
the deletion of the array", does it mean that the python buffer object
ref count won't be decremented ? Or, more generally, the created
numarray will refer directly to the C array segments exposed by the
python buffer object or will keep a reference to this object?
> Not in my opinion, for two reasons:
>
> 1. PyArray_FromDimsAndData is easier to use, internalizing the buffer
> creation step.
>
> 2. These days, my recommendation is to use the Numeric compatibility
> layer because it gives the best portability, to Numeric now and to
I will take your advice.
Thank you!
Regards,
Carlos
More information about the NumPy-Discussion
mailing list