On Sat, Oct 12, 2013 at 8:07 AM, Nick Coghlan <ncoghlan@gmail.com> wrote:
One interesting point is that combining collections.Counter.elements() with itertools.permutations() currently does the wrong thing, since itertools.permutations() *always* considers iterable order significant, while for collections.Counter.elements() it's explicitly arbitrary.
I hadn't thought about it, but as I read the docs for 3.4 (and it's the same back through 2.7), not only would both of these be permissible in a Python implementation:
list(collections.Counter({'a':2,'b':1}).elements()) ['a', 'a', 'b']
Or:
list(collections.Counter({'a':2,'b':1}).elements()) ['b', 'a', 'a']
But even this would be per documentation (although really unlikely as an implementation):
list(collections.Counter({'a':2,'b':1}).elements()) ['a', 'b', 'a']
-- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.