Raymond Hettinger added the comment:

At its most basic, a Counter is simply a dictionary with a __missing__ method 
that supplies a default of zero.  It is intentional that everything else 
behaves as much like a regular dictionary as possible.  You're allowed to store 
*anything* in the dict values even if those values don't represent numbers.  A 
consequence is that equality is taken to mean the same a regular dict equality.

The unary-plus is provided as a way to eliminate zeros from a Counter prior to 
doing a Counter equality test.

Other designs were possible (such as my Bag class mentioned in the docs).  This 
one was selected for its versatility, but it does present challenges with 
respect to zeros, negatives, fractions, etc.  I recognize your concern but find 
it to be at odds with the basic design of the class.  You might be happier with 
a Multiset class that restricts itself to positive integer counts.

----------
priority: normal -> low
resolution:  -> rejected
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14182>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to