Message228443
On Sat, Oct 04, 2014 at 08:38:17AM +0000, Ram Rachum wrote:
>
> Ram Rachum added the comment:
>
> > There are some properties of set comparison:
> >
> > (a < b) == (a <= b and a != b)
>
> I don't think so, because counter equality is based on dict equality so it doesn't ignore zero values.
That's a very good point! That suggests that we shouldn't treat Counters
as multisets (a.k.a. bags) and define subset/superset operators. They're
*almost* multisets, but not quite the same, since:
Counter({'a': 0}) != Counter({})
but the formal definition of multiset suggests those should be equal:
https://en.wikipedia.org/wiki/Multiset#Formal_definition
Perhaps we should rethink this. I'm starting to wonder whether we need a
PEP to define exactly how subset and superset should be defined for
Counters. This is precisely the trouble with rushing to add code before
we know what the code is supposed to do... :-) |
|
Date |
User |
Action |
Args |
2014-10-04 10:13:25 | steven.daprano | set | recipients:
+ steven.daprano, rhettinger, mark.dickinson, pitrou, scoder, eric.smith, r.david.murray, cool-RR, ethan.furman, serhiy.storchaka, Saimadhav.Heblikar, josh.r |
2014-10-04 10:13:25 | steven.daprano | link | issue22515 messages |
2014-10-04 10:13:25 | steven.daprano | create | |
|