For those with:
-
ancient browsers that won't run that memory graph web debugger
-
the attention span of a pigeon and can't be bothered to read a long explanation that doesn't address this particular pycon
>>> import copy
>>>
>>> a = [[0]]
>>> c1 = a
>>> c2 = a[:]
>>> c3 = list(a)
>>> c4 = a.copy()
>>> c5 = copy.copy(a)
>>> c6 = copy.deepcopy(a)
>>>
>>> c1[0].append(1)
>>> c2[0].append(2)
>>> c3[0].append(3)
>>> c4[0].append(4)
>>> c5[0].append(5)
>>> c6[0].append(6)
>>>
>>> print(a)
[[0, 1, 2, 3, 4, 5]]
copy.deepcopy makes a separate memory copy into c6. So appending to c6 affects c6, but not a