[issue40755] Add missing multiset predicates to collections.Counter

2020-05-31 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset b7d79b4f36787874128c439d38397fe95c48429b by Raymond Hettinger in 
branch 'master':
bpo-40755: Add rich comparisons to Counter (GH-20548)
https://github.com/python/cpython/commit/b7d79b4f36787874128c439d38397fe95c48429b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-30 Thread Vedran Čačić

Vedran Čačić  added the comment:

I'm very glad for that. :-)

For the other part of my message, I never intended to remove the support for 
non-natural counts. I just wanted to add some more methods to the natural part 
of Counter's API. It already has some methods which assume natural counts: 
.elements(), for example.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-30 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
pull_requests: +19792
pull_request: https://github.com/python/cpython/pull/20548

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-30 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

After more thought, I've found a way to use the rich comparisons as requested.  
Doing so consistently required that the __eq__ method treat missing elements as 
having a zero count.  See attached PR.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I would also have preferred to use the operators <, >, <=, >=, and ==.  The 
docs in the patch explain why we can't go down this path.

Also, while counters have support for multiset operations, they continue to 
support other use cases a well (negative counts and fractional counts). That 
support can't be removed without breaking existing code that relies on it.

>From the outset, a Counter was just a dictionary that return 0 for missing 
>keys.  Users are free to use that concept however they want.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 60398512c86c5535edd817c99ccb50453b3b0471 by Raymond Hettinger in 
branch 'master':
bpo-40755: Add missing multiset operations to Counter() (GH-20339)
https://github.com/python/cpython/commit/60398512c86c5535edd817c99ccb50453b3b0471


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-25 Thread Vedran Čačić

Vedran Čačić  added the comment:

isequal is really strange considering we're talking about Python here. Do any 
of other stdlib types have that method instead of just using == (which works 
fine even now)? I'd even spell the second and third as <= and >=, same as set 
does.

But if we're finally going to accept that Counters are just bags (CS term for 
multisets), then surely .add and .remove (and maybe .discard, setting the count 
to 0) would be more natural additions. I can't count (pun intended) all the 
times I had to write that '] += 1' just to count some element.

--
nosy: +veky

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-24 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
keywords: +patch
pull_requests: +19623
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/20339

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40755] Add missing multiset predicates to collections.Counter

2020-05-24 Thread Raymond Hettinger


New submission from Raymond Hettinger :

These missing predicates have been requested a number of times:

   isequal()
   issubset()
   issuperset()
   isdisjoint()

--
assignee: rhettinger
components: Library (Lib)
messages: 369808
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Add missing multiset predicates to collections.Counter
type: enhancement
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com