How Dicts Compile

May 30, 2026 | 5 min read

Creation

{a: 1, b: 2} uses fast initialisation.

Lookup

d[key] uses inline hash cache for string keys.

Insertion

d[key] = value resizes and inserts inline.

Iteration

for k in d iterates keys with cached table layout.