Counter Class -- Bag/Multiset

Terry Reedy tjreedy at udel.edu
Fri Jan 23 04:03:54 EST 2009


msrachel.e at gmail.com wrote:

> The term counter was what was originally approved.  At first, I didn't
> like it but found that it had some advantages.  The main advantage is
> that there are *bazillions* of programmers (including some very good
> ones) who have never heard the term multiset or bag but have an
> instant,
> intuitive understanding of counting and counters.
> 
> Also, in the context of this implementation, "multiset" would not be a
> good choice.  The mathematical entity, multiset, is defined with
> elements
> having a count of one or more.  In contrast, the Counter class allows
> counts to go to zero or become negative.  In addition, I worried that
> calling it a multiset would suggest that it has a set-like API instead
> of a dict-like API.  With the former, you write c.add(elem).  With the
> latter, you write c[elem] += 1.  So the name, "multiset" would be
> misleading.

Agreed.  I withdraw my objection.




More information about the Python-list mailing list