[Tutor] Can someone explain this to me please

Laura Creighton lac at openend.se
Fri Aug 21 21:24:15 CEST 2015

In a message of Fri, 21 Aug 2015 14:04:18 -0400, Jon Paris writes:
>This code:
>import sys
>x = sys.maxsize
>print ("Max size is: ", x)
>y = (x + 1)
>print ("y is", type(y), "with a value of", y)
>Produces this result:
>Max size is:  9223372036854775807
>y is <class 'int'> with a value of 9223372036854775808
>I was expecting it to error out but instead it produces a value greeter than the supposed maximum while still keeping it as an int. I’m confused. If sys.maxsize _isn’t_ the largest possible value then how do I determine what is?
>Jon Paris
>jon.f.paris at gmail.com

If you go over sys.maxsize, Python will just get you a long.
The idea is to do away with the distinction between long and int.
see: https://www.python.org/dev/peps/pep-0237/


More information about the Tutor mailing list