The addition of two numbers in Python is fascinating ⚡

Arpit Bhayani

Arpit Bhayani

Mar 30, 2024 • 1 min read


The addition of two numbers in Python is 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 is how it supports infinitely long numbers with ease while being efficient.

If you are interested, do go through the source code of CPython, one of the best codebases out there https://lnkd.in/gs9cd9SM

⚡ I keep writing and sharing my practical experience and learnings every day, so if you resonate then follow along. I keep it no fluff.

arpitbhayani.me/course

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