Why every attribute lookup in your dynamic language is secretly a hash table

Objects, attributes, maps, oh my

Dynamically typed languages make objects look like simple name-to-value maps, so many VMs implement them as hash tables. That's technically O(1) but costs hundreds of CPU instructions and extra memory loads on every `a.b`. The fix is maps, also called shapes or hidden classes: immutable, tree-structured layouts that turn string lookups into small integer offsets, stored inline and reused through inline caches. The post walks through a compact Python implementation, showing how a pointer check on the map replaces hashing.

This means that literally every operation `a.b` is doing hundreds or thousands of CPU instructions, including multiple dependent memory loads. This is _not good_ for performance.

More from this day

2026-10-23