Objects, attributes, maps, oh my
Web page · https://bernsteinbear.com/blog/object-shapes
First seen by Oriel on .
AI summary
The article explains how object shapes replace per-object attribute hash tables with immutable layouts, enabling compact storage and fast attribute access through inline caches.
- A shape maps attribute names to storage offsets, and adding an attribute moves an object to a new shape in a shared transition tree.
- Inline caches remember a shape and attribute index; matching objects can load by index, while misses perform a name lookup and refresh the cache.
- Objects with different classes can share a shape, improving cache reuse but meaning shape alone cannot identify an object’s class.
- Attribute insertion order affects shapes, and objects with many fields may fall back to hash-table storage; type-specialized shapes can also reduce runtime guards.
#object shapes #inline caches #dynamic languages #jit compilers
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Hacker News: 20, latest observation ; +15 over observed period since
- Lobsters: 27, latest observation ; +25 over observed period since
Comments
Comment count reported by the source.
- Hacker News: 1, latest observation ; +1 over observed period since
- Lobsters: 5, latest observation ; +5 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Hacker News | 50197692 | https://bernsteinbear.com/blog/object-shapes/ Read discussion |
| Lobsters | 8rkyrl | https://bernsteinbear.com/blog/object-shapes/ Read discussion |