[Python-ideas] Suggestion: Extend integers to include iNaN

Chris Angelico rosuav at gmail.com
Sun Sep 30 11:03:11 EDT 2018

On Mon, Oct 1, 2018 at 12:58 AM David Mertz <mertz at gnosis.cx> wrote:
>> I'm not sure what's going on. I have a Py3 busily calculating
>> 2**(2**65) and it's pegging a CPU core while progressively consuming
>> memory, but it responds to Ctrl-C, which suggests that Python bytecode
>> is still being executed.
> I'm not quite sure, but my guess is that at SOME POINT you'll get an overflow exception when the current value gets too big to store as a native int.  Or maybe it'll be a segfault; I don't know.
> I'm also not sure if you'll see this error before or after the heat death of the universe ;-).
> I *am* sure that your swap space on your puny few terabyte disk will fill up before you complete the calculation, so that might be a system level crash not a caught exception.

Hahahaha. I was trying to compare to this:

>>> "a" * (2**63 - 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>

Bam, instant. (Interestingly, trying to use 2**63 says "OverflowError:
cannot fit 'int' into an index-sized integer", suggesting that
"index-sized integer" is signed, even though a size can and should be
unsigned.) Were there some kind of hard limit, it would be entirely
possible to exceed that and get an instant error, without actually
calculating all the way up there. But it looks like that doesn't

In any case, the colloquial definition that I usually cite ("Python
can store infinitely big integers" or "integers can be as big as you
have RAM to store") is within epsilon of correct :D

Thanks for the info. Cool to know!


More information about the Python-ideas mailing list