3 ms·
That hash values get distributed differently inside the hash to avoid collision attacks is totally unrelated to what iteration order you get when you iterate el
by yxhuvud 5y ago
That hash values get distributed differently inside the hash to avoid collision attacks is totally unrelated to what iteration order you get when you iterate elements in the hash. You can easily get predictable iteration order and have hash collisions that is not predictable.
Look at Python, Ruby, PHP - they have defined iteration order to be insertion order. Javascript also have predictable order though the order is a bit more complex. Go is the outlier in that it defines it as guaranteed to be random. But both choices are just fine.
- masklinn 5y ago> totally unrelated to what iteration order you get when you iterate elements in the hash That is a bit too strong am assertion: you can decorrelate the two when you build the collection, but the naive set up is very much that hash randomisation will randomise iteration order.