[Numpy-discussion] how to get data out of an object array in pyrex?

Jeff Whitaker jswhit at fastmail.fm
Mon Feb 6 05:01:09 CST 2006

Travis Oliphant wrote:
> Jeff Whitaker wrote:
>> Hi:  I've successfully used the examples at 
>> http://www.scipy.org/Wiki/Cookbook/Pyrex_and_NumPy to access the data 
>> in a 'normal' numpy array, but have had no success adapting these 
>> examples to work with object arrays.  I understand that the .data 
>> attribute holds pointers to the objects which actually contain the 
>> data in an object array, but how to you use those pointers to get the 
>> data in C/pyrex?
> You have a pointer to a PyObject *object in the data.  Thus, data 
> should be recast to PyObject **.  I don't know how to do that in PyRex.

Apparently not.  If I try to do this pyrex says

115:25: Pointer base type cannot be a Python object

>   But, it's easy in C.
> In C, you will need to be concerned about reference counts. 
OK, I was hoping to avoid hand-coding an extension in C (which I'm 
woefully unqualified to do).


Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : Jeffrey.S.Whitaker at noaa.gov
325 Broadway                Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg

More information about the Numpy-discussion mailing list