"O(1) lookup isn't free forever — it's a promise the hash map keeps by quietly growing itself before it gets too crowded. Stop the growing and the promise breaks."
The Load Factor
The load factor is the ratio of stored entries to available slots: load = entries / slots. It's the single number that predicts a hash map's health. At a low load (say 0.3), keys are spread thin, collisions are rare, and lookups are crisply O(1). As the load climbs toward 1, slots fill up, collisions pile on, chains lengthen (or probe sequences stretch), and your O(1) quietly rots toward O(n). The load factor is the gauge on the dashboard — watch it and you know whether the map is healthy.
The Fix: Grow and Rehash
When load factor crosses an implementation-chosen threshold, a hash table allocates more capacity and relocates entries. That O(n) event is rare enough to preserve amortized O(1) insertion. The exact threshold and growth factor depend on the collision strategy and implementation; neither two-thirds nor exact doubling is a language contract.
Where the Threshold Sits
Chaining can operate above load factor 1 at the cost of longer chains, while open addressing needs empty slots to keep probes short. CPython's exact policy may change across versions. Remember the invariant—spare capacity controls expected probe length—not one magic fraction.