[Python-Dev] counterintuitive behavior (bug?) in Counter with +=

Raymond Hettinger raymond.hettinger at gmail.com
Fri Oct 7 13:39:32 CEST 2011


On Oct 3, 2011, at 6:12 AM, Lars Buitinck wrote:

>  After some digging, I found out that Counter [2] does not
> have __iadd__ and += copies the entire left-hand side in __add__!

This seems like a reasonable change for Py3.3.


> I also figured out that I should use the update method instead, which
> I will, but I still find that uglier than +=. I would submit a patch
> to implement __iadd__, but I first want to know if that's considered
> the right behavior, since it changes the semantics of +=:

Yes, update() is the fastest way.


Raymond

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20111007/11e4170a/attachment.html>


More information about the Python-Dev mailing list