25/40
Part 5 of 7 · Inside a dictLearn and do

How a dictionary works, and when it's slow

The Python FAQ sums it up: CPython's dictionaries are hash tables that resize. Here is what happens inside one, in CPython 3.12.

A dict keeps its entries in order, and their positions in a table

Predict

A dict gets the keys 12, 33, 7 and 42, in that order. In what order does list(d) give them back?

Pick an answer above to see the rest