Answer
A deep copy recursively copies an object and its contained objects when appropriate. • copy.deepcopy() tracks objects already copied to handle cycles and shared references. • Some objects are intentionally returned unchanged or need custom copy behavior. • Deep copying can be expensive and is not always the correct ownership model.
💡 Simple Example
import copy
original = [[1], [2]]
cloned = copy.deepcopy(original)
cloned[0].append(9)
print(original)
print(cloned)
Output
[[1], [2]]
[[1, 9], [2]]
⚡ Quick Revision
A deep copy recursively separates nested mutable objects.