Deep Copy

say it: “DEEP KOP-ee” /dip ˈkɑpi/

A copy of a collection and everything inside it, fully separate.

What is a deep copy?

A deep copy copies a collection and everything inside it, so the copy is completely separate from the original.

import copy
teams = [["Ana"], ["Ben"]]
backup = copy.deepcopy(teams)
backup[0].append("Cai")
print(teams)  # [['Ana'], ['Ben']]: untouched

Level: Journeyman · More Python terms at this level

Updated

In other subjects