|
From: Sasha <nd...@ma...> - 2006-02-17 23:43:43
|
On 2/17/06, Travis Oliphant <oli...@ee...> wrote: > ... > Perhaps what is going on is that > a +=3D 10 > is begin translated to > a =3D a + 10 > rather than > add(a,10,a) > I'll have to look deeper to see why. It is actually being translated to "a =3D add(a,10,a)" by virtue of array_inplace_add supplied in the inplace_add slot. Here is the proof: >>> a =3D array(0) >>> a =3D b =3D array(0) >>> a +=3D 10 >>> b array(10) >>> a 10 Another way to explain it is to note that a +=3D 10 is equivalent to "a =3D a.__iadd__(10)" and a.__iadd__(10) is equivalent to "add(a, 10, a)". This is not easy to fix because the real culprit is >>> a =3D array(0) >>> type(a) is type(a+a) False Maybe we can change ufunc logic so that when the output argument is supplied it is returned without scalar conversion. |