[Numpy-discussion] C-API creating new copy of C data

Bill Baxter wbaxter@gmail....
Thu Apr 19 02:51:58 CDT 2007


What's the right way to make a new numpy array that's a copy of some C data?

There doesn't seem to be any API like PyArray_NewFromDescr that
/copies/ the void*data pointer for you.  Do I have to write my own
loops for this?  I can do that, it just seems like it should be a
library function already, so I'm guessing I'm just overlooking it.
There seem to be lots of APIs that will wrap pre-existing memory, but
the ones that allocate for you do not seem to copy.

A related question -- I'm only trying to copy in order to save myself
a little hassle regarding how to clean up the allocated chunks.  If
there's some simple way to trigger a particular deallocation function
to be called at the right time, then that would be the ideal, really.
Does that exist?

Thanks!
--bb


More information about the Numpy-discussion mailing list