Interned Objects
These are the cached PyObjects
which python does for optimizations and performance.
- All integers -5 to 255 are cached.
- Strings that contain ASCII letters, digits, or underscores only.
For example,
a = 1
b = 1
a is b # True
sys.getrefcount(a)
sys.getrefcount(b)
# both gives same result
Both a
and b
points to the same Python Object (PyObject
).