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

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