You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.