I want to understand how I can control the "random seed" that's used in set.pop
to select the arbitrary element to be popped.
Consider this example:
>>> for _ in range(5):
... x = {b'a', b'b', b'c'}
... print(x.pop())
...
b'a'
b'a'
b'a'
b'a'
b'a'
It seems as though the process for popping an element from the x
set is deterministic. However, there is something set under the hood that fixes this deterministic behaviour. If I run this from another terminal (i.e. another python session), I get a different, but still deterministic result:
>>> for _ in range(5):
... x = {b'a', b'b', b'c'}
... print(x.pop())
...
b'c'
b'c'
b'c'
b'c'
b'c'
How can I have reproducibility across different python processes for the set.pop
method?