Mar-29-2018, 05:18 AM
Obviously the call
id(A.__dict__)
allocates a new object of type mappingproxy, that is to say a smart pointer. You are printing the id of these smart pointers. In the examples above, when B.__dict__
is accessed, the mappingproxy created for A.__dict__
is already destroyed, so the same address is reused. If you keep a reference to the proxy, two different addresses are used>>> x = A.__dict__ >>> y = B.__dict__ >>> id(x), id(y) (140355706316360, 140355683451672)