A shallow copy creates a new object but still references the same nested objects as the original, while a deep copy recursively copies everything, so the new object is fully independent.
This distinction only matters for objects that contain other objects, like a list of lists — copying simple, flat data (like a list of numbers) behaves the same either way.
import copy
original = [[1, 2], [3, 4]]
shallow = copy.copy(original)
shallow[0][0] = 99
print(original) # [[99, 2], [3, 4]] — original changed too!
The outer list is new, but the inner lists inside it are still the same shared objects as in the original.
deep = copy.deepcopy(original)
deep[0][0] = 99
print(original) # unchanged — fully independent copy
A deep copy recursively duplicates every nested object, so modifying the copy never affects the original, no matter how deeply nested the data is. Deep copies use more memory and take longer, so shallow copies are preferred when the data structure doesn't contain nested mutable objects.
Last reviewed: September 2026