[Numpy-discussion] Numarrays from C arrays without copying

Todd Miller jmiller at stsci.edu
Thu Apr 22 09:58:18 CDT 2004


On Thu, 2004-04-22 at 11:47, Paul F. Dubois wrote:
> This is what PyArray_FromDimsAndData was for, and I believe it is fairly 
> heavily used.

That's good to know.  I was just discussing with Perry how to expand the
C-API to support this stuff.  Perhaps we don't have to.

> Todd Miller wrote:
> > On Thu, 2004-04-22 at 08:51, Ville Hakulinen wrote:
> > 
> >>Dear all,
> >>
> >>I would like to turn a large C array allocated by a library into a
> >>Numarray object without copying the contents. In other words I have
> >>a given array of double precision floats and I want to get a Numarray
> >>object, where the data pointer points to this array and no additional
> >>memory is allocated. Naturally when the reference count of the Numarray
> >>object gets back to zero, the object is freed, but the array itself
> >>is left as a nuisance for the C code.
> >>
> >>Is there a standard way of doing this?
> > 
> > 
> > No, not yet.  You're not the first person to ask for this but I'd
> > appreciate it if you'd explain why you need it.  So far,  not having
> > that feature is a conscious omission to keep complexity down.
> > 
> > Regards,
> > Todd
> > 
-- 
Todd Miller <jmiller at stsci.edu>





More information about the Numpy-discussion mailing list