4 ms·
Fun fact: not only is the iteration order of sets in python unordered, it's also undeterministic! A set of the same values, iterated in two python program, coul
by cdrini 4y ago
Fun fact: not only is the iteration order of sets in python unordered, it's also undeterministic! A set of the same values, iterated in two python program, could iterate in a different order.
I learned this when a unit test that iterated over a set started failing sporadically :P super confusing bug!
- olejorgenb 4y agoI think this is just for sets whos items hash derive from `hash(some_string)` (eg.: sets of strings) This is because the string hash function is randomized on process startup to help prevent DOS attacks: https://stackoverflow.com/q/30585108/1517969 https://stackoverflow.com/q/30585108/1517969