[Cython] construction numpy arrays
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Thu Nov 13 20:14:52 CET 2008
Robert Bradshaw wrote:
> On Nov 13, 2008, at 6:35 AM, Uwe Schmitt wrote:
>
>> Hi,
>>
>> is there a fast and simple way to convert a given
>> chunk of memory to a coresponding numpy array ?
>> Or do I have to construct the array entry by entry ?
>
> You can grab the numpy underlying data as a void* and do a memcpy.
> Perhaps you can even avoid the memcpy, but I'm not sure.
>
There are ways of handing off the memory to NumPy arrays directly, but
it is not very trivial. This question is better asked on the NumPy
mailing list; as it's been answered in various forms there before and
they will know it a lot better (I don't know the details myself).
--
Dag Sverre
More information about the Cython-dev
mailing list