Add portable way to extract all digits of a `PyLongObject` from C?

Definitely. There are many situations where you don’t want to pay the price of a Python method call just to access the value of a long integer.

I’d rather not expose this implementation detail. If we add a C API, it should probably just call into the existing implementation to convert into 8-bit digits, or at most, 64-bit digits. Especially since the request is for a portable API.

Otherwise we’ll one day discover that some other sized digit makes more sense, and then we have to write the conversion into 30 bits. May as well start by reusing the conversion we already have.

4 Likes