[Numpy-discussion] PyArray_Resize reference counting

Ravi lists_ravi@lavabit....
Tue Sep 30 16:20:51 CDT 2008


On Tuesday 30 September 2008 16:26:08 Travis E. Oliphant wrote:
> You need to do something like:
>
> temp = PyArray_Resize(array,...)
> Py_DECREF(array)
> array = temp

In this case, since a new array may be returned, is there no way to 
synchronize with other objects holding a reference to the original array? In 
other words, let's say A, B and C hold references to X, a numpy array. Then, 
if C needs to resize the array, the newly resized array is not available to A 
and B since their references are to the old array. Since C will typically not 
know about A and B, should resizing be disallowed (by me as a programmer 
writing code for A, B and C) in order to ensure that the arrays as seen by 
them do not go out of sync?

Regards,
Ravi




More information about the Numpy-discussion mailing list