Hacker News new | ask | show | jobs
by dataflow 657 days ago
> Word to the wise... as of Python 3.7, the regular dictionary data structure guarantees order.

Which means you still should use it if you might run on 3.6 or earlier.

1 comments

Even for 3.6 it's still true, just not guaranteed in writing: https://stackoverflow.com/a/39980744/5044950

And Python <=3.7 is already end-of-life anyways: https://devguide.python.org/versions/

This hit me bad once bad. I tested the regular dict and it _looked_ like it was ordered. Turned out, 1 out of about 100000 times it was not. And I had a lot of trouble identifying the reason 3 weeks later, when the bug was buried deep in complex code, and it appeared mostly what looked like random.