When I have a list a
, I can create a shallow copy of a
by the following four different methods:
a = [1, 2, 3]
b = list(a)
b = a.copy()
b = a[:]
import copy
b = copy.copy(a)
Here, I am wondering whether they always give the same result b
, or possibly are there some cases (of a
) that may give different results for b
? (I guess performance may be different between the above methods, but here I am interested in the value of b
rather than computational efficiency.)
2