SMRTR ProgrammingAug 16, 2025John D. Cook

Converting very long strings to integers in Python

SMRTR summary

Python sets limits on string-to-integer conversion at 4300 digits, as revealed when attempting to convert a 5382-digit prime number. Though Python integers have no size limit beyond available memory, direct string conversion fails with a SyntaxError. The problem was solved by breaking the number into smaller strings and performing manual radix conversion.

SMRTR provides this summary for quick context. The original article belongs to John D. Cook.

Read the original article
SMRTR Programming

Get the next batch of curated summaries in your inbox.

This archive is built from SMRTR newsletter summaries. Subscribe for hand-picked stories without the extra noise.