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 rhettinger
Recipients ethan.furman, josh.r, rhettinger
Date 2014-10-11.07:19:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1413011971.52.0.871495479813.issue22533@psf.upfronthosting.co.za>
In-reply-to
Content
> It is my thought that a Counter with all its keys set to zero 
> is as empty as a Counter with no keys

If the counter were a stand-alone multiset or bag class, this might be a reasonable thing to do.

However, for better or for worse, the design of the counter is primarily "a dict with a __missing__ that returns 0 and adds some handy methods useful in the context of dicts being used for counting".   This gives it flexibility, simplicity, speed, and makes it more or less substitutable for regular dicts in functions that expect regular dicts.  IIRC, this is the basic design that Guido endorsed when the idea of a counter was first proposed.

> I agree it's sort of weird, but I feel like fixing it will 
> just break a ton of existing code.

It is sort of weird, but that was the intended behavior (trying to keep the counter as dict-like as possible), and you're correct that changing it now would risk either breaking or substantially slowing code existing code.
History
Date User Action Args
2014-10-11 07:19:31rhettingersetrecipients: + rhettinger, ethan.furman, josh.r
2014-10-11 07:19:31rhettingersetmessageid: <1413011971.52.0.871495479813.issue22533@psf.upfronthosting.co.za>
2014-10-11 07:19:31rhettingerlinkissue22533 messages
2014-10-11 07:19:30rhettingercreate