Explains how dynamic-language objects modeled as per-object name→value hash tables pay heavy costs in hashing and memory indirection, and shows how runtimes replace that with maps (aka shapes/hidden classes): immutable, persistent-tree descriptors that map attribute names to small integer slots and identify an object's in-memory layout. As attributes are added, maps produce new map nodes (next_map) and objects carry a map pointer plus a storage array indexed by slots. This removes string hashing from the fast path, enables inline attribute storage in low-level implementations, and gives a stable, cheap-to-compare layout identifier so callers can detect layout changes quickly.
Gives compact Python sketches for Base/Class/Instance, Map.get_index/next_map, and an InlineCache that caches a (map, index) pair and uses pointer equality to fast-path loads by index; on a miss it falls back to name lookup, updates the cache, and returns the value. Notes Python lacks true in-object inline storage, but the pattern still reduces loads and instructions in an interpreter; production runtimes and JITs use the same concepts and more aggressive optimizations to eliminate interpreted overhead and accelerate attribute access.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.