Python supports really long integers, practically infinite, but when it

Arpit Bhayani

Arpit Bhayani

Aug 30, 2025 • 1 min read


Python supports really long integers, practically infinite, but when it comes to adding two such long integers, what Python does is something really fascinating…

Python literally does what we are taught in school. Go digit by digit and maintain a carry.

But, instead of working on decimal digits, Python stores the number in base 2^31 and adds them digit by digit. This way, it ensures an efficient utilization of the 32-bit width of regular integers.

If you are interested in digging deeper into CPython, here’s the link to the source code referencing this operation. By the way, I also have a short series on CPython internals on my YouTube channel; the link to both is in the comments.

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses