Thursday, December 3, 2026 | London 10°C · Drizzle
DailyGlimpse

AI

Python 3.14 Patches Subtle Dict Ordering Bug, Making Code More Reliable

Unbearable TechTips 1 min read

Python 3.14 fixes a long-standing bug in dictionary insertion order that could silently break code relying on stable ordering after key deletion and reinsertion. Discovered by Hugo van Kemenade, the flaw caused reinserted keys to appear at the end of the dictionary instead of their original position. This could lead to unexpected behavior in any program that depended on predictable ordering after mutations.

The new compacted dict layout preserves logical position across deletions and reinsertions, fixing the issue without changing any APIs. This means that all code using ordered dictionaries (which have been guaranteed insertion-ordered since Python 3.7) becomes more trustworthy without requiring any changes from developers.

For more details, see Hugo van Kemenade's post: "Fixing the dictionary with Python 3.14".

React