Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- Wrong title, article has "How Does Python’s OrderedDict Maintain Order?"
- Title of the article is "How…", not "Why…", and "why" is not discussed. (My understanding is that the "why" is "because the implementation acted that way without an official guarantee, and folks depended on the implementation detail, so it became guaranteed.)by addaon
- ^ came here to say exactly thisby more_corn
- Thanks, How makes much more sense. The post title is dumb.
Why is Hackernews news for hackers?
by snthpy - I don't think this is the "why". What you're depicting is what happened in JavaScript. Dictionary keys in Python always had that (to me) annoying property that they preserved insertion order until they don't. I'd frankly much prefer if they'd always be iterated in random order each time they're traversed.
- I was under that impression as well, but it was added as an implementation in 3.6 (https://bugs.python.org/issue27350), so I don't know that too many people would have become dependent on it before it was official in 3.7: https://docs.python.org/3/whatsnew/3.7.html
I think the "how/why" thing is just the automatic title de-clickbait-ifer going a little haywire?