Can Python's set absence of ordering be considered random order? Can Python's set absence of ordering be considered random order? python python

Can Python's set absence of ordering be considered random order?


No, it is not random. It is "arbitrarily ordered", which means that you cannot depend on it being either ordered or random.


No, you can not rely on it for any real statistical purpose. The implementation of sets in Python is in terms of a hash table, and can cause the element distribution to display some very non-random properties. There's a large gap between "not having a guaranteed order" and "guaranteed to be unordered in a uniform-random manner".

Use random.shuffle to really shuffle elements of a sequence.


In a word, no:

>>> list(set(range(10000))) == list(range(10000))True