[Numpy-discussion] Conversion functions between Numeric and numarray arrays?

Francesc Alted falted at openlc.org
Tue Jan 21 11:24:11 EST 2003


A Dimarts 21 Gener 2003 19:41, Sebastian Haase va escriure:
> Hi,
> I think this is actually quite related to my post from Friday:
> [Numpy-discussion] make C array accessible to python without copy
>
> -> So, to reformulate: Who hold actually the array data in memory? Or:
> where gets the memory allocated and where/how many pointers to that exist? 
>   I understood the answer that Todd Miller gave, that there is such a thing
> as a "buffer object" that does all the work, so then: one would just have
> to take that and build a "new" numarray or Numeric structure around it 
> (referring to the Subject of this email)   or  (in the case of my
> Friday-email)  just have that "buffer object" point to a different memory
> space (that got already allocated by the C-program) .
>
> Agree ? (Did I get it right?)

Well, so so. I think the buffer object is a property of numarray objects,
not Numeric objects. So, in the numarray ==> Numeric conversion process you
may need to access the internals of the buffer (for example by using the
high level numarray C-API) and manage to obtain a data buffer (in the C
sense, not an object) that can be used to build the Numeric object (with the
help of the numarray object metadata). The opposite way needs something
similar but with inverted roles. See my previous message for a more in-depth
explanation.

I think the conversion (without copying) is not a difficult process, but no
so-easy like that.

Well, I'm just a newcomer to numarray and my opinions about that may
perfectly be completely wrong, of course. Take them with caution!.

-- 
Francesc Alted




More information about the NumPy-Discussion mailing list