[issue14828] itertools.groupby not working as expected
Jiba
report at bugs.python.org
Wed May 16 13:08:15 CEST 2012
Jiba <jibalamy at free.fr> added the comment:
Ok, I understand.
However, in my initial problem, the sequence passed to groupby was a set, e.g. (modifying my previous example) :
groupby(set([p1, p2, p3]), lambda p: p.key)
If I understand well how groupby() works, the result of a groupby performed on a set is unpredictable, since it depends of the order of the items when iterating over the set. Perhaps the behavior of groupby() should be modified for unsorted sequences, possibly not taking the order into account, or raising an error ?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14828>
_______________________________________
More information about the Python-bugs-list
mailing list