
On Apr 22, 2004, at 7:10 AM, Todd Miller wrote:
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.
The reason I need this is two fold: 1. I want to export to Python existing Fortran arrays. If you want Fortran and Python to share array memory, you can't always expect Fortran programmers to use memory allocated in Python. In fact, since there is no standards conforming way to associate a Fortran array pointer with Python memory, you have to do the opposite, associate a Python array with Fortran memory. 2. In the CoArray Python module, we MUST use special memory allocators that are parallel aware. Because of these requirements, our only choice is to use Numeric. Regards, Craig