LinkedIn Reddit icon

Dunder Doc

by Valdir Stumm Jr

How Does CPython Multiply Big Numbers?

I am used to write code that multiplies numbers several times a week. Usually when I do that, I don’t think much about the operation itself or how the machine will execute it. But if we start thinking about it, how in hell can the CPython interpreter multiply numbers as large as the ones below? The CPU definitely does not support huge numbers like that out of the box, so how does it work?

CPython Optimizations

CPython is the reference implementation of the Python language. While there are several other implementations, CPython is by far the most popular one. These days, it comes bundled in most of the operating systems. Even though CPython is not the most performatic Python interpreter out there, it does some very interesting optimizations to speed itself and Python programs up. I am pretty curious about things like these and the rationale behind them, even though I know very little about it.