negative "counts" in collections.Counter?

Gregory Ewing greg.ewing at
Mon Mar 8 23:22:28 CET 2010

Raymond Hettinger wrote:

> Instead the choice was to implement the four methods as
> multiset operations.  As such, they need to correspond
> to regular set operations.

Seems to me you're trying to make one data type do the
work of two, and ending up with something inconsistent.

I think you should be providing two types: one is a
multiset, which disallows negative counts altogether;
the other behaves like a sparse vector with appropriate
arithmetic operations.


More information about the Python-list mailing list