On Sun, Oct 16, 2011 at 5:52 PM, Ganesh Gopalakrishnan <gan...@cs.utah.edu> wrote: > This probably is known, but a potential pitfall (was, for me) nevertheless. > I suspect it is due to hash collisions between 's3' and 's13' in this case? > It happens only rarely, depending on the contents of the set.
I'm not sure exactly which keys are colliding here, but in general the iteration order of a set (or dict) depends not just on the contents, but also on the order of insertion. And of course the repr depends on the iteration order -- anything consistent would require sorting, which would be O(n log n) and is not even necessarily well-defined. -- http://mail.python.org/mailman/listinfo/python-list