[Python-Dev] Comparison operators (> < >= <=) for collections.Counter (original) (raw)
Kerrick Staley kerrick at kerrickstaley.com
Tue Sep 8 04:06:17 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 495: What's left to resolve
- Next message (by thread): [Python-Dev] Comparison operators (> < >= <=) for collections.Counter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I noticed that collections.Counter, unlike set, doesn't support the ordered comparison operators (> < >= <=). I'd like to propose implementing these operators in an analogous fashion to set: counter1 >= counter2 if counter1 contains at least as many of every key as counter2 does. Cases where counter1 doesn't have a key and counter2 has a negative amount of that key would still count as >=. counter1 > counter2 when counter1 >= counter2 and counter1 != counter2.
Does this sound reasonable? If so I'll write up and submit a patch.
- Kerrick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150907/ea2214a8/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 495: What's left to resolve
- Next message (by thread): [Python-Dev] Comparison operators (> < >= <=) for collections.Counter
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]