标签: python python-3.x variables memory-management
为什么c和d具有相同的内存ID?
c
d
class A: def __init__(self, number): self.n = number a = A(1) b = A(1) id(a) == id(b) # False L1 = [1, 2, 3] L2 = [1, 2, 3] id(L1) == id(L2) # False
但是
c = 1 d = 1 id(c) == id(d) # True