bags? 2.5.x?
Raymond Hettinger
python at rcn.com
Thu Jan 17 21:18:53 EST 2008
> >> I keep wanting something like them - especially bags with something
> >> akin to set union, intersection and difference.
>
> > How about this recepie
> > <URL:http://www.ubookcase.com/book/Oreilly/
>
> The author of the bag class said that he was planning to submit bags for
> inclusion in 2.5 - is there a particular reason why they didn't go in?
Three reasons:
1. b=collections.defaultdict(int) went a long way
towards meeting the need to for a fast counter.
2. It's still not clear what the best API would be.
What should list(b) return for b.dict = {'a':3, 'b':0, 'c':-3}?
Perhaps, [('a', 3), ('b', 0), ('c', -3)]
or ['a', 'a', 'a']
or ['a']
or ['a', 'b', 'c']
or raise an Error for the negative entry.
3. I'm still working on it and am not done yet.
Raymond
More information about the Python-list
mailing list