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 Saimadhav.Heblikar, cool-RR, eric.smith, ethan.furman, josh.r, mark.dickinson, pitrou, r.david.murray, rhettinger, scoder, serhiy.storchaka, steven.daprano
Date 2014-10-11.07:37:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1413013052.42.0.0161958102107.issue22515@psf.upfronthosting.co.za>
In-reply-to
Content
> I suggest implementing `Counter.__lt__` which will be a 
> partial order, similarly to `set.__lt__`.

This would be reasonable if the counter were a strict stand-alone multiset or bag; however, the core design is much looser than that (supporting negative counts for example).

It would be more accurate to think about the Counter as a dict that returns 0 for missing keys and has few extra methods that can be handy in the content of counting things.

Accordingly, a partial ordering operator wouldn't be well-defined for some of the intended use cases. 

The addition of subset/superset operations was considered and rejected during the original design phase (the omission was intentional).  It is better to leave this to the user to decide what they want to do and how they intend to do so.  After all, it is as easily to work with as a regular dict.  You can access it directly or subclass it to fit your own needs.

The starting point for this class (when first proposed and endorsed by Guido) was:

   class Counter(dict):
       def __missing__(self, key):
           return 0

That core idea is dirt simple and it is not hard to build your own variants if the one in collections doesn't meet your needs.
History
Date User Action Args
2014-10-11 07:37:32rhettingersetrecipients: + rhettinger, mark.dickinson, pitrou, scoder, eric.smith, steven.daprano, r.david.murray, cool-RR, ethan.furman, serhiy.storchaka, Saimadhav.Heblikar, josh.r
2014-10-11 07:37:32rhettingersetmessageid: <1413013052.42.0.0161958102107.issue22515@psf.upfronthosting.co.za>
2014-10-11 07:37:32rhettingerlinkissue22515 messages
2014-10-11 07:37:31rhettingercreate