[Numpy-discussion] Pointers to arrays in C
Tue Jun 3 12:27:09 CDT 2008
Lisandro Dalcin wrote:
> I believe in your current setup there is no better way. But you should
> seriously consider changing the way of using array data. Storing bare
> pointers in the C side and not holding a reference to the object
> providing the data in the C side is really error prone.
as you are passing a ndarray into your C code, another option is that
you could increase the reference count to that array in your C code
(Py_INCREF). Then it would not be destroyed on the Python side. However,
you'd have to make sure you Py_DECREF it when you don't need it anymore.
There may be a way to tell the array that is does not "own" the data
block also, but I don't know the numpy API enough to tell you how to do
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the Numpy-discussion