Re: [Numpy-discussion] PyArray_Resize reference counting

2008-10-01 Thread Ravi
On Tuesday 30 September 2008 18:54:21 Travis E. Oliphant wrote: > I just went to the code and noticed that PyArray_Resize returns None.   > So, you certainly don't want to point array to it.  The array does not > get any reference count changes. Thanks for the very clear explanation. > PyObject *

Re: [Numpy-discussion] PyArray_Resize reference counting

2008-09-30 Thread Travis E. Oliphant
Ravi wrote: > 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 o

Re: [Numpy-discussion] PyArray_Resize reference counting

2008-09-30 Thread Ravi
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 ori

Re: [Numpy-discussion] PyArray_Resize reference counting

2008-09-30 Thread Travis E. Oliphant
Ravi wrote: > Hi, > Consider the following code: > >PyArrayObject *array = get_me_an_array_along_with_a_reference(); /* 1 */ >PyArray_Dims *dims = get_me_some_dims(); /* 2 */ >array = (PyArrayObject *)PyArray_Resize( array, dims, 1 ); /* 3 */ > > Is the code above valid? No. You nee

[Numpy-discussion] PyArray_Resize reference counting

2008-09-30 Thread Ravi
Hi, Consider the following code: PyArrayObject *array = get_me_an_array_along_with_a_reference(); /* 1 */ PyArray_Dims *dims = get_me_some_dims(); /* 2 */ array = (PyArrayObject *)PyArray_Resize( array, dims, 1 ); /* 3 */ Is the code above valid? In particular, is the assigment on line