This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lars
Recipients lars
Date 2011-10-07.08:50:32
SpamBayes Score 0.000504677
Marked as misclassified No
Message-id <>
I've found some counterintuitive behavior in collections.Counter while hacking on the scikit-learn project [1]. I wanted to use a bunch of Counters to do some simple term counting in a set of documents, roughly as follows:

   count_total = Counter()
   for doc in documents:
       count_current = Counter(analyze(doc))
       count_total += count_current

Performance was horrible. After some digging, I found out that Counter [2] does not have __iadd__ and += copies the entire left-hand side in __add__. I've attached a patch that fixes the issue (for += only, and I've not patched the testsuite.)

Date User Action Args
2011-10-07 08:50:34larssetrecipients: + lars
2011-10-07 08:50:34larssetmessageid: <>
2011-10-07 08:50:33larslinkissue13121 messages
2011-10-07 08:50:33larscreate