{
  "id": 16090187,
  "title": "Objects, attributes, maps, oh my",
  "url": "https://urgent.news/2026/10/22/objects-attributes-maps-oh-my",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-22T17:35:52.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://bernsteinbear.com/blog/object-shapes/"
  },
  "original_language": "en",
  "account": "Many dynamically typed programming languages, such as Python, model objects as a collection of names and corresponding values. This design allows for flexibility and encourages the use of a hash table to map names to values within the virtual machine (VM). For example, a Python sketch demonstrates this object model using functions like write_attr and read_attr to access object attributes.\n\nTo improve performance, runtime implementers often create special data structures called maps, layouts, shapes, or hidden classes. These structures optimize the reading, writing, and storage of attributes. The implementation of these maps can be complex, with various edge cases and high-level overviews present in many blog posts. However, understanding the basics of this system can be challenging.\n\nIn this article, the author examines the CF Bolz-Tereick's \"A Simple Object Model\" and extracts the core features of a map system. The map serves three main purposes: acting as an index or write-through cache, reflecting the layout of a given object, and providing a stable identifier for a particular in-memory layout. This structure allows for quick checks to determine if the object's layout has changed, enabling faster loading of data.\n\nThe author also presents a Python implementation of objects with maps and the maps themselves. Although the storage is not in-line, as initially promised, the common case still reads and writes attributes using string names. The author notes that the index storage would typically be in-line in languages such as C++ or Rust. The implementation provides an efficient way to look up attributes, with a fast check followed by an indexed load in the common case. This approach aims to reduce the number of memory loads and improve overall performance.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}