Slicing in python is supposed to make a shallow copy. However, when I run the following:
cur = [[0] * (2) for _ in xrange(2)]
cur2 = [row[:] for row in cur]
cur2[0][0] = "foo"
print(cur)
print(cur2)
I get:
[[0, 0], [0, 0]] # cur
[['foo', 0], [0, 0]] # cur2
which makes it seem like it's a deep copy.
I have two questions: 1) What's happening here? Is this a deep or shallow copy? 2) What about this syntax makes it so much faster than copy.deepcopy? For example, is it something with the way python manages memory?