What is the difference between shallow copy, deepcopy and normal assignment operation?
The difference between shallow and deep copying is only relevant for
compound objects (objects that contain other objects, like lists or
class instances):
The difference between shallow and deep copying is only relevant for
compound objects (objects that contain other objects, like lists or
class instances):
After E0_copy = list(E0), I guess E0_copy is a deep copy of E0 since id(E0) is not equal to id(E0_copy). Then I modify E0_copy in the loop, but why is E0 not the same after?
I want to copy a 2D list, so that if I modify one list, the other is not modified.
The official Python docs say that using the slicing operator and assigning in Python makes a shallow copy of the sliced list.
I would like to make a deepcopy of a function in Python. The copy module is not helpful, according to the documentation, which says:
It does “copy” functions and classes (shallow and deeply), by
returning the original object unchanged;