What are the max and min values of integer in Python?

Learn Python integer limits using sys.maxsize for 64-bit systems, and understand why Python integers are arbitrary precision.

Using the maxsize method

There is a sys module which will help us to answer the above questions. Maxsize method will tell us the max value of integer in Python.

import sys

print(sys.maxsize)

It turns out the max integer is exactly 9223372036854775807 which is 2^63-1.

See also  Interactive Dashboards with Dash and Python

However, to display the minimum value, use one of the following:

import sys
minSize = -sys.maxsize - 1
print(minSize)

or

import sys
minSize = ~sys.maxsize
print(minSize)

Min value of an integer is -9223372036854775808.