3

I read that sys.maxsize is the largest value Python 3's int can hold. However, it seems not to be the case; I can put much bigger number and it still does not overflow.

What is the limit that int can hold in Python 3? I am asking because I am converting a string to an integer and I am wondering if I need to worry about a possibility of overflow when doing the conversion.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
leopoodle
  • 2,110
  • 7
  • 24
  • 36
  • 3
    Possible duplicate of [Maximum and Minimum values for ints](http://stackoverflow.com/questions/7604966/maximum-and-minimum-values-for-ints) – jonrsharpe Dec 09 '16 at 22:26
  • 1
    [*"there is no longer a limit to the value of integers"*](http://stackoverflow.com/a/26121781/3001761) – jonrsharpe Dec 09 '16 at 22:26
  • Depends on how much memory is available to the Python interpreter on your systems (they can be any size that free memory allows). – martineau Dec 09 '16 at 22:41

1 Answers1

3

From the docs what's new page:

The sys.maxint constant was removed, since there is no longer a limit to the value of integers. However, sys.maxsize can be used as an integer larger than any practical list or string index. It conforms to the implementation’s “natural” integer size and is typically the same as sys.maxint in previous releases on the same platform (assuming the same build options).

morsecodist
  • 907
  • 7
  • 14