[Numpy-discussion] subtle behavior when subtracting sub-arrays

Pauli Virtanen pav@iki...
Mon Jul 5 09:23:58 CDT 2010

Mon, 05 Jul 2010 16:03:56 +0200, Steve Schmerler wrote:
> To sum up, I find it a bit subtle that
>     a = a - a[...,0][...,None]
> works as expected, while
>     a -= a[...,0][...,None]
> does not.
> I guess the reason is that in the latter case (and the corresponding
> loop), a[...,0] itself is changed during the loop, while in the former
> case, numpy makes a copy of a[...,0] ?


> Is this intended?

Not really. It's a "feature" we're planning to get rid of eventually, 
once a way to do it without sacrificing performance in "safe" cases is 

Pauli Virtanen

More information about the NumPy-Discussion mailing list