News for hackers. Stuff that matters.
Re:Python dicts are now ordered by kyrra on Friday February 07, 2020 @10:52AM (#22267126)
Go purposely "randomizes" order of a map when it's iterated over, which you can see running this demo:

https://play.golang.org/p/DISpyv0Zuq_j

HN discussed this a little 6 years ago: https://news.ycombinator.com/item?id=7655948

As crawshaw pointed in that discussion, it helps catch people inadvertently relying on map order in tests or other places in their code.

Re:Python dicts are now ordered by ipsin on Friday February 07, 2020 @11:04AM (#22267286)
More important (in my opinion), adding a random seed to your hash prevents collision attacks, where an attacker tries to ruin your performance by sending many values (e.g. HTTP params) that would hash to the same bucket.
Re:Python dicts are now ordered by tomp on Friday February 07, 2020 @11:55AM (#22267945)
Many (most?) programming language runtimes now do this, especially the web-focused ones. But it's completely orthogonal to insertion-ordered iteration (which is implemented by a list).
Re:Python dicts are now ordered by throwaway8291 on Friday February 07, 2020 @11:03AM (#22267265)
That surprised me, when I first saw it. If someone takes a minute to read the docs (e.g. Python), one would never build something knowing that order is not guaranteed (e.g. order in dictionaries). But seemingly people do.
Re:Python dicts are now ordered by UncleEntity on Friday February 07, 2020 @11:54AM (#22267926)
Had some code break while porting from 2 to 3 because it assumed dict order and it was part of the official Python build system, the old spark parser for the AST module.