[Numpy-discussion] PyArray_Resize reference counting

Ravi lists_ravi@lavabit....
Wed Oct 1 14:21:29 CDT 2008


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 *dummy;
> dummy = PyArray_Resize(array, ...)
> if (dummy == NULL) goto fail;
> Py_DECREF(dummy)
>
> is what you need to do.

If dummy is NULL, is the original array guaranteed to be unchanged (strong 
exception safety with rollback semantics)? If not, is the original array 
guaranteed to be at least in an internally consistent state (weak exception 
safety)?

In general, do functions modifying numpy arrays provide at least weak 
exception safety guarantee? Or do they go one step further and provide 
rollback semantics in case of exceptions?

Regards,
Ravi




More information about the Numpy-discussion mailing list