jargon

Design patterns·Functional ideas that went mainstream

the copy was free until somebody wrote to it, and only then did the data actually get duplicated.

Copy-on-write

Also calledcopy on write, COW, lazy copy

Sharing one underlying representation between a value and its copies until one of them is modified, at which point that one is duplicated. It gives value semantics at reference-semantics cost for the common read-only case, and it is how several standard library collections and most process forks work. Its performance cliff is the write nobody expected to be expensive, which is the same shape as every other lazy optimisation.

Commonly confused with