[Python-Dev] In-place operators
Terry Reedy
tjreedy at udel.edu
Wed Mar 18 02:17:03 CET 2009
Raymond Hettinger wrote:
> Does anyone think it was not a good idea to put in-place operations in
> the operator module? For some objects, they don't map() as well as
> their regular counterparts. Some in-place operations rely on the
> interpreter to take care of the actual assignment. I've not yet seen
> good use cases for operator.isub() for example.
Given that Python has augmented assignment delimiters, but no 'in-place
operators', and that the 'in-place operations' used to partially
implemented them cannot be 'in-place' for immutables (and hence are
actually aliases for the corresponding 'regular' operations, I agree
that they are a bit odd and mostly useless. About the only use case I
can think of is something like map(operator.iadd, mutable_seqs, items),
where mutable_seqs includes instances of user classes than defind
.__iadd__ but not .append ;-)
On the other hand, the kitchen-sink policy saves debate.
tjr
More information about the Python-Dev
mailing list