November 3, 2025
Order in the court!
Why is Python's OrderedDict ordered?
Commenters roast the 'Why' vs 'How' title mix-up and relive Python’s journey to ordered dicts
TLDR: The piece explains how Python’s OrderedDict keeps items in order and why it still exists despite modern dicts keeping order. Comments erupt over a “Why” vs “How” headline mismatch, with readers split between nitpicking the title and praising a clear, useful explainer of a still-relevant tool.
Python’s OrderedDict is back in the spotlight, but the real show is the comments section. The article walks through how it works—think a list of keys that keeps their place, plus a normal dictionary for fast lookups—and why it still exists: old code, some extra features, and a quirky rule about comparing order. But the crowd pounced on the headline first. The vibe? Headline court is in session. Multiple readers say the piece explains “how,” not “why,” while the actual “why” (Python dictionaries officially keep insertion order since 3.7—see the docs here) gets a drive-by mention.
Strongest opinions? The “title police” vs. the “content enjoyers.” One camp says labeling matters; the other shrugs and says the explainer is solid, especially with neat bits like move_to_end from OrderedDict. A veteran crowd chimed in with nostalgia for the pre-3.7 chaos, while newcomers joked “order in the court!” and posted mock trials for the headline. The only real technical mini-drama: a reminder that OrderedDict treats order as part of equality while plain dicts don’t—cue jokes about “same stuff, different vibes.” In the end, readers stayed for the clean walkthrough of the doubly linked list + dictionary trick, but they came for the headline roast.
Key Points
- •Since Python 3.7, dicts preserve insertion order, but OrderedDict remains in the standard library.
- •OrderedDict differs from dict by treating key order as part of equality and offering extra methods like move_to_end.
- •OrderedDict inherits from dict for storage and performance, adding structures to track order efficiently.
- •It uses a doubly linked list for O(1) inserts/deletes and a separate dict to map keys to linked-list nodes for O(1) lookups.
- •Operations like __setitem__, __delitem__, and pop update both the underlying dict and the linked-list structures to maintain order.