top | item 45756058

Why is Python's OrderedDict ordered?

13 points| misonic | 4 months ago |piglei.com

17 comments

order

addaon|4 months ago

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.)

DemocracyFTW2|4 months ago

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.

snthpy|3 months ago

Thanks, How makes much more sense. The post title is dumb.

Why is Hackernews news for hackers?

more_corn|3 months ago

^ came here to say exactly this

DemocracyFTW2|4 months ago

Wrong title, article has "How Does Python’s OrderedDict Maintain Order?"