Deep vs Shallow Copy
Deep vs Shallow Copy¶
- Facts and Myths about Python | YouTube.com Ned Batchelder
In [0]:
from copy import deepcopy
In [0]:
a = []
b = []
c = []
some_list = [a, b, c]
some_other_list = some_list # Shallow Copy
a.append(42)
print(some_other_list)
In [0]:
a = []
b = []
c = []
some_list = [a, b, c]
some_other_list = deepcopy(some_list) # Deep Copy
a.append(42)
print(some_other_list)
In [0]: