I run below python code, a and b will point to the same object as I know.
>>> a=10
>>> b=10
>>> a is b
True
but when I change the 10 to a bigger number such as 100000, the result is weird.
>>> a=100000
>>> b=100000
>>> a is b
False
It seems that python create two 100000 in memory.
Then I try below code:
>>> lst=[10,10]
>>> lst[0] is lst[1]
True
>>> lst=[100000 ,100000 ]
>>> lst[0] is lst[1]
True
In list the numbers (10 or 100000) are both in same object.
That's what I confused. Why when the number is bigger, Python create two object? and why in List, it still use one copy?