Insertion order is a language guarantee backed by the compact dict layout
Before Python 3.7, dict iteration order was an implementation detail and could change between versions or runs. CPython 3.6 introduced the compact dict representation, which stores entries in a dense array in insertion order and uses a separate sparse indices array for hash lookup. That made insertion order natural. In Python 3.7, this behavior was elevated to a language specification guarantee, so all compliant implementations must preserve insertion order. Deletion does not reorder remaining keys, but re-inserting a deleted key appends it to the end.
The order is insertion order, not sorted order and not access order.
If you delete a key and add it again, it moves to the end.
OrderedDict still exists because it offers move_to_end, popitem(last=...), and order-sensitive equality. Plain dict equality ignores order.
Common mistake: assuming dict order equals sorted order or that updating a value changes key position. Updating a value does not move the key.
Version note: 3.6 was a CPython implementation detail; 3.7 made it a language guarantee. Code that relies on order should still state Python 3.7+.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience