jargon

Design patterns·Wrapping and composing

a million objects turned into a thousand shared ones plus a million positions, because most of the data was identical.

Flyweight

Also calledflyweight pattern, shared instance, interning

Sharing one immutable instance across many logical objects by splitting the data that is common from the data that is not. Almost nobody implements it deliberately today, but everyone uses it: string interning, boxed integer caches, glyph and texture caches are all flyweights. It earns its place in this corpus because it is asked about in interviews and because recognising it explains why two identical small integers can be reference-equal in some languages.

Commonly confused with