Memory Scaling: How Large Integers Grow in Python

While Python reuses pre-allocated objects for small integers (-5 to 256), larger integers incur the base 28-byte overhead plus additional memory for their value, growing in 4-byte increments as the number of digits in base 2^30 increases; for example, 2^30 requires 32 bytes.

Open the full topic