[Numpy-discussion] performing operations in-place in numpy

Gael Varoquaux gael.varoquaux@normalesup....
Thu Jul 9 09:51:25 CDT 2009

On Thu, Jul 09, 2009 at 09:35:06AM +0000, Pauli Virtanen wrote:
> Thu, 09 Jul 2009 10:03:47 +0100, Citi, Luca kirjoitti:
> [clip]
> > Excuse me if I insist, PyArray_Conjugate is not the problem. If when
> > using the numpy API, it is accepted something like:

> >     obj1 = PyArray_CreateSomehowAnArray(....);
> >     obj2 = PyArray_DoSomethingWithArray(obj1,...); 
> >     obj3 = PyArray_DoSomethingElseWithArray(obj1,...); 
> >     Py_DECREF(obj1);

> > then there is no way my patch is guaranteed to not break things.

> So it seems.

> PyUFunc_GenericFunction is a part of the public C-API, so I guess this 
> discussion is moot. I doubt we can change ufunc semantics at this point, 
> and I don't see ways in which one could distinguish between "temporary 
> arrays" and refcount-1 arrays used in extension modules.

OK, so from what I understand, the proposed change what induce a major
change on the C API. So it seems that we can't just merge it in.

However, I really like the idea: I think it is a simple and clever
optimisation, that is transparent to the user. Do you think it is
possible to keep it around, think about it, and merge it in later, eg in
numpy 2.0?


More information about the NumPy-Discussion mailing list