[Numpy-discussion] Shouldn't all in-place operations simply return self?

Alan G Isaac alan.isaac at gmail.com
Thu Jan 17 09:32:34 EST 2013


Is it really better to have `permute` and `permuted`
than to add a keyword?  (Note that these are actually
still ambiguous, except by convention.)

Btw, two separate issues seem to be running side by side.

i. should in-place operations return their result?
ii. how can we signal that an operation is inplace?

I expect NumPy to do inplace operations when feasible,
so maybe they could take an `out` keyword with a None default.
Possibly recognize `out=True` as asking for the original array
object to be returned (mutated); `out='copy'` as asking for a copy to
be created, operated upon, and returned; and `out=a` to ask
for array `a` to be used for the output (without changing
the original object, and with a return value of None).

Alan Isaac



More information about the NumPy-Discussion mailing list