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

Original title: Objects, attributes, maps, oh my

> Hacker News story 50197692 · language: en · submitted 2026-10-22
> Web version: https://zeli.app/story/50197692
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 21 · by [ibobev](<https://news.ycombinator.com/user?id=ibobev>) · 💬 1
[original](<https://bernsteinbear.com/blog/object-shapes/>) · [HN discussion](<https://news.ycombinator.com/item?id=50197692>)

## Summary

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.

## Key quote

> 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.

---

## Cite

- Page: https://zeli.app/story/50197692
- Date: 2026-10-22
- Source: bernsteinbear.com (https://bernsteinbear.com/blog/object-shapes/)
- Hacker News: https://news.ycombinator.com/item?id=50197692

## Other languages

- zh: https://zeli.app/zh/story/50197692 · markdown: https://zeli.app/zh/story/50197692.md
- ja: https://zeli.app/ja/story/50197692 · markdown: https://zeli.app/ja/story/50197692.md
- ko: https://zeli.app/ko/story/50197692 · markdown: https://zeli.app/ko/story/50197692.md
- de: https://zeli.app/de/story/50197692 · markdown: https://zeli.app/de/story/50197692.md
- es: https://zeli.app/es/story/50197692 · markdown: https://zeli.app/es/story/50197692.md
- ru: https://zeli.app/ru/story/50197692 · markdown: https://zeli.app/ru/story/50197692.md
