What is the difference between shallow copy and deep copy?
Variables, references, and memory model
Audio flashcard · 0:17Nortren·
What is the difference between shallow copy and deep copy?
0:17
A shallow copy creates a new container but reuses references to the inner objects. A deep copy recursively copies all nested objects. The copy module provides copy.copy for shallow and copy.deepcopy for deep copies. Shallow copies are faster but can lead to bugs when nested mutable objects are unintentionally shared.
docs.python.org