对一个似乎非常基本/微不足道的问题抱歉,但我不理解以下行为:
>>> id_1 = id(256)
>>> id_2 = id(256)
>>> id_1 == id_2
True
>>> id_1 = id(257)
>>> id_2 = id(257)
>>> id_1 == id_2
False
>>> id_1 = id("ab")
>>> id_2 = id("ab")
>>> id_1 == id_2
True
>>> id_1 = id("aa")
>>> id_2 = id("aa")
>>> id_1 == id_2
False
>>> id_1 = id(' ')
>>> id_2 = id(' ')
>>> id_1 == id_2
False
>>> id_1 = id(('A', 'Z'))
>>> id_2 = id(('A', 'Z'))
>>> id_1 == id_2
True
>>> id_1 = id(('A', 'Z', 'AA'))
>>> id_2 = id(('A', 'Z', 'AA'))
>>> id_1 == id_2
False
内置函数id
给出相同的对象引用/地址的特殊情况之间的区别是什么(我曾经看到的是0-256,包括两者,'a' - 'z' ,'A' - 'Z')?