[Numpy-discussion] Numpy array from ctypes pointer object?
oliphant.travis at ieee.org
Wed Jul 12 14:25:59 CDT 2006
Mark Heslep wrote:
> Travis Oliphant wrote:
>> Mark Heslep wrote:
>>> I don't see a clean way to create a numpy array from a ctypes pointer
>>> object. Is the __array_interface_ in ctypes the thing thats missing
>>> needed to make this happen? I've followed Albert's Scipy cookbook
>>> on ctypes here
>>> On the C side the PyArray_SimpleNewFromData( ..dimensions, ...data
>>> ptr) C API does the job nicely. Is there a ctypes paradigm for
>> Can you somehow call this function using ctypes?
> That might work, though indirectly. As I think I understand from ctypes
> docs: Ctypes uses functions exposed in a shared library, macros
> existing only a header are not available. If its PyArray... is a macro
> then I a) need to compile and make a little library directly from
> arrayobject.h or b) need to use the root function upon which the macro
> is based, PyArrayNew?
This is more complicated because all the C-API functions are actually
just pointers stored in _ARRAY_API of multiarray. So, something would
have to be built to interpret the C-pointers in that C-Object. I'm not
sure that is possible.
More information about the Numpy-discussion