[Python-Dev] Augmented assignment

Neil Schemenauer nascheme@enme.ucalgary.ca
Thu, 15 Jun 2000 16:26:35 -0600


On Thu, Jun 15, 2000 at 11:30:45PM +0200, Peter Funk wrote:
> Augmented assignments are unPythonic because they don't add any new 
> functionality to the language.
[...]
> 	foo[bar()] = foo[bar()] + bar()
> versus
> 	foo[bar()] += bar()

Not quite.  I think with the proposed implementation += could
modify the LHS object in place.  This could be a big performance
win for things like NumPy objects.  OTOH, the same effect can be
achieved with a method call:

    foo[bar()].add(bar())

  Neil