python会缓存小的整数和短小的字符

经过测试,python会缓存的小整数的范围是 [-5, 256] 

# True
a = 1
b = 1
print(a is b)

# True
a = "good"
b = "good"
print(a is b)

# False
a = "very good morning"
b = "very good morning"
print(a is b)

# False
a = []
b = []
print(a is b)

  

posted @ 2019-07-10 11:57  世纪强风  阅读(332)  评论(0编辑  收藏  举报