Sets iterate in arbitrary order
Closed this issue · 3 comments
veit commented
They can often appear ordered, but this is not mandatory:
>>> s1 = set(range(19))
>>> s2 = set(range(19))
>>> for i in range(1, 19, 2): s2.remove(i)
...
>>> for i in range(1, 19, 2): s2.add(i)
...
>>> s2
{0, 2, 4, 6, 8, 9, 10, 7, 12, 5, 14, 1, 16, 3, 18, 11, 13, 15, 17}
>>> s1 == s2
Trueveit commented
krother commented
in my opinion this is not necessary; the example is interesting but a special case. The remark that sets are not ordered should be sufficient.