Python's Integer Interning: Small Number Memory Hack

Python optimizes memory for frequently used integers from -5 to 256 by "interning" them, creating single shared objects to avoid repeated 28-byte allocations and boost performance.

Sources

Open the full topic