How does Python assign memory addresses for literals?
>>> id(1)
4298171352
>>> id(2)
4298171328
>>> id(1.0019)
4299162496
>>> id(1.0025)
4299162496
>>> id(1.00999)
4299162496
>>> a = 1.0025
>>> b = 1.00999
>>> id(a)
4299162496
>>> id(b)
4299162472
>>>
jg@jg ~ $ python
Python 2.7.10 |Anaconda 2.2.0 (x86_64)| (default, May 28 2015, 17:04:42)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> id(1)
4298171352
How is it that 1.0025 and 1.0999 correspond to the same memory location, but when I set a and b equal to those respective values there are now different memory locations? How is it that when I restart Python, the memory address for 1 is the same?
Also, does this mean that there is a pre-existing memory address for every integer and binned floats and character?