import copy
a = [12, 13, 15, 15, 14, 10]
d = copy.deepcopy(a)
print(id(d) == id(a))
print(id(d[0]) == id(a[0]))
e = copy.copy(a)
print(id(e) == id(a))
print(id(e[0]) == id(a[0]))
#outputs
False
True
False
True
I am using Python 3.4 and according to What exactly is the difference between shallow copy, deepcopy and normal assignment operation?, for d
I should get outputs False
and False
, for e
I should get outputs False
and True
.
Any ideas why this is happening?
After I changed a
to [12, 13, 15, 15, 14, [10, 12]]
and then checked id(d[5])
vs id(a[5])
the IDs were different. So, why aren't the IDs different for d[0]
and a[0]
?