Stephen J. Turnbull wrote:
> Worse, running the same program again with the *same* set can change
> which element is first, I believe.
Yes, this is correct. For example, if you had a minimal Python file named "some_set.py" with only the following:
```
s = set('abcdefg')
```
and then run something like this "import some_set; print(list(some_set.s))" the order of the elements will be randomized each time. Within each individual interpreter, the order will not change though (including if you del and then import some_set again):
```
[aeros:~]$ python -c "import some_set; print(list(some_set.s)); print(list(some_set.s))"
['f', 'a', 'c', 'g', 'b', 'd', 'e']
['f', 'a', 'c', 'g', 'b', 'd', 'e']
[aeros:~]$ python -c "import some_set; print(list(some_set.s)); print(list(some_set.s))"
['a', 'd', 'f', 'b', 'e', 'g', 'c']
['a', 'd', 'f', 'b', 'e', 'g', 'c']
[aeros:~]$ python -c "import some_set; print(list(some_set.s)); del some_set; import some_set; print(list(some_set.s))"
['f', 'b', 'g', 'e', 'c', 'a', 'd']
['f', 'b', 'g', 'e', 'c', 'a', 'd']
[aeros:~]$ python -c "import some_set; print(list(some_set.s)); del some_set; import some_set; print(list(some_set.s))"
['c', 'e', 'a', 'f', 'g', 'b', 'd']
['c', 'e', 'a', 'f', 'g', 'b', 'd']
```
IIUC, the "ordering seed" for all sets is randomly determined when the interpreter is first created, and remains the same throughout its lifespan. I'm not 100% certain that it's interpreter dependent, but it seems like it would be.
Personally, I don't think this makes `first()` any worse off though. I think it should be expected that attempting to extract the "first" element from an unordered container would not consistently return same one.