# Copy-on-Write

*noun*

say it: **“KOP-ee on RYT”** **/ˈkɑpi ɑn ˈraɪt/**

A way of handling copies where a copy shares the original's data until one of them is changed, so copying is cheap and the original stays safe.

## What is **Copy-on-Write** in pandas?

**Copy-on-Write** is how pandas 3 handles copies: a copy shares its data with the original until one of them
changes, and only then is the data really copied. Copying is cheap, and changing a copy never changes the original.
A chained assignment, such as `df["temp_f"][0] = 61.8`, changes nothing; set one value with `.loc` instead.

```python
readings.loc[0, "temp_f"] = 61.8      # changes the table
# readings["temp_f"][0] = 61.8       # chained assignment: changes nothing in pandas 3
```

## In a sentence

- “Under **Copy-on-Write**, the chained assignment left the table unchanged.”
- “Thanks to **Copy-on-Write**, df.copy() at the start of each step costs almost nothing.”

Level: Freelancer · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=4)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/copy-on-write
