What is the Max and Minimum Value of int type in Python?

Python Max and Min Int value example

If you come from a programming background of Java or C#, you would have known that there is a limit to the max and the min size of an integer datatype based on the underlying system architecture (which is -231 to -231-1 for 64 bit Operating Systems)

But, do you know that the int data type is an arbitrary precision integer, which means that it can represent integers of any size without overflow.


"An integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a 64-bit platform."


import sys

print(f"Max Int: {sys.maxsize}") 
print(f"Min Int: {-sys.maxsize - 1}")
Max Int: 9223372036854775807
Min Int: -9223372036854775808

Have Questions? Post them here!