[Numpy-discussion] (Late) summary of PEP-225 discussion at Scipy
David Warde-Farley
dwf@cs.toronto....
Wed Oct 29 18:37:56 CDT 2008
On 29-Oct-08, at 3:43 PM, Robert Kern wrote:
> Eh, that's not entirely true.
>
> x = 1
> x += 2
>
> That's not in-place. They are called "augmented assignments", not
> "in-place operations" for this reason. The defining characteristic is
> that "x <op>= y" should be equivalent to "x = x <op> y" except
> possibly for *optional* in-place semantics.
Indeed.
x = "foo"
x += "bar"
This definitely isn't in-place, since strings are immutable, but it
works, and people expect it to work.
Of course it's worth mentioning in the docs somewhere that only the
augmented assignments for element-wise ops are in-place (which should
be obvious to anyone who knows what an outer product is).
David
More information about the Numpy-discussion
mailing list