[Numpy-discussion] memory-mapped Numeric arrays: arrayfrombuffer version 2

Konrad Hinsen hinsen at cnrs-orleans.fr
Fri Jan 25 11:26:05 EST 2002


Kragen Sitaker <kragen at pobox.com> writes:

> There is one thing in arrayfrombuffer.c I'm not sure about, and
> I could use some help here.  arrayobj is the return value from
> PyArray_FromDimsAndData:
>   /* do I need to incref arrayobj?! fromstring does... */
>   return (PyObject*)arrayobj;
> }
> 
> So, do I?  Or not?  It seems to work as it is.

And it is correct, in my opinion. Your routine is the owner of the
array (and no one else keeps a reference), so you just pass on
ownership. Doing an INCREF here would mean that the array is never
freed. (Keep in mind that the data area is never freed anyway!)

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------




More information about the NumPy-Discussion mailing list