Python integer and memory
Memory allocation
>>> id(5)
11381600
>>> x = 5
>>> id(x)
11381600
>>> y = 5
>>> id(y)
11381600>>> y = 7
>>> id(7)
11381664
>>> id(y)
11381664PyObject
Last updated
>>> id(5)
11381600
>>> x = 5
>>> id(x)
11381600
>>> y = 5
>>> id(y)
11381600>>> y = 7
>>> id(7)
11381664
>>> id(y)
11381664Last updated
>>> 11381664 - 11381600
64
>>> id(7) - id(5)
64
>>> 64 / 2
32.0>>> import ctypes
>>> ctypes.cast(11381600, ctypes.py_object).value
5
>>> ctypes.cast(11381600 + 32, ctypes.py_object).value
6
>>> ctypes.cast(11381600 + 64, ctypes.py_object).value
7>>> id(260)
140219535811728
>>> x = 260
>>> id(x)
140219536828848>>> x = 360; y = 360
>>> id(x)
140219535811696
>>> id(y)
140219535811696