14/37
Part 3 of 6 · OrderedDictLearn and do
A plain dict can fake the order, but its evictions slow down until it rebuilds its table
A plain dict keeps insertion order too. You can fake both moves: d[k] = d.pop(k) for move_to_end, and next(iter(d)) for the oldest key. In the same benchmark, get stayed fast: 0.23 µs at 100,000 entries. Evicting didn't, because of where a dict keeps its entries:
A plain dict fakes the LRU order, and next(iter(d)) finds the oldest key. Why do its evictions get slower as they go on?
Pick an answer above to see the rest