Calling iter() on a set in Python seems to sort the set in place.
Example:
>>> my_set = {2, 1, 3}
>>> _ = iter(my_set)
>>> my_set
{1, 2, 3}
I am wondering why is that's the case. I guess it has something to do with the way __iter__ or __next__ are implemented for set in cPython but I am not sure.
Any idea is welcome.
EDIT
As pointed by answers and comments below, the _ = iter(my_set) does not change the results - my_set prints 'ordered'. The reasons are explained in details here.