As explained in Can Python's set absence of ordering be considered random order?, the set structure is in arbitrary order. For example, the following code results in different output between runs.
idList = [ "ID" + str(i) for i in range(10) ]*10
idSet = set(idList)
print(idSet)
I would like to understand what internally causes this unpredictable behaviour. Why does the same code and input produce different output? Is it dependent on the memory addresses used by Python, the availability of data in some cache or does for example the implementation/algorithm include some random elements?