Re: [Numpy-discussion] Numarrays from C arrays without copying

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@stsci.edu>

On Apr 22, 2004, at 10:57 AM, Todd Miller 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.
So is there an equivalent NA_FromDimsAndData? I have been using PyArray_FromDimsAnd Data. Craig

On Thu, 2004-04-22 at 14:34, Craig Rasmussen wrote:
On Apr 22, 2004, at 10:57 AM, Todd Miller 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.
So is there an equivalent NA_FromDimsAndData?
No. I was making the mistake of thinking there needed to be.
I have been using PyArray_FromDimsAndData.
That's fine and should basically work. Between numarray and Numeric there is currently the not-so-subtle difference that numarray copies the external data buffer and Numeric just refers to it. This is a documented difference, but my vote is for changing in favor of better functionality and Numeric compatibility. I'll probably just quietly change it unless there is a deluge of dissenters... -- Todd Miller <jmiller@stsci.edu>
participants (2)
-
Craig Rasmussen
-
Todd Miller