C
candide
Suppose a Python program defines an integer object with value 42. The
object has an "address" we can capture with the built-in function id() :
Now I was wondering if any integer object with value 42 will be refered
at the same adress with the above id.
Some experiments tend to show that it may be the case, for instance :
152263540
152263540
Even you can't make a deep copy :
So is the following true :
Two non mutable objects with the same value shall be allocated at a
constant and unique address ?
object has an "address" we can capture with the built-in function id() :
Now I was wondering if any integer object with value 42 will be refered
at the same adress with the above id.
Some experiments tend to show that it may be the case, for instance :
152263540
>>> d={"foo":42, "bar":"foo"}
>>> id(d["foo"]) 152263540
>>> L=["foo",(51,([14,42],5)),"bar"]
>>> id(L[1][1][0][1]) 152263540
>>> del a
>>> id(L[1][1][0][1])
152263540
>>> zzz=range(1000)
>>> id(zzz[42]) 152263540
>>>
Even you can't make a deep copy :
So is the following true :
Two non mutable objects with the same value shall be allocated at a
constant and unique address ?