int and long were "unified" a few versions back. Before that it was possible to overflow an int through math ops.
3.x has further advanced this by eliminating long altogether and only having int.
- Python 2:
sys.maxintcontains the maximum value a Python int can hold.- On a 64-bit Python 2.7, the size is 24 bytes. Check with
sys.getsizeof().
- On a 64-bit Python 2.7, the size is 24 bytes. Check with
- Python 3:
sys.maxsizecontains the maximum size in bytes a Python int can be.- This will be gigabytes in 32 bits, and exabytes in 64 bits.
- Such a large int would have a value similar to 8 to the power of
sys.maxsize.
Top answer 1 of 9
182
int and long were "unified" a few versions back. Before that it was possible to overflow an int through math ops.
3.x has further advanced this by eliminating long altogether and only having int.
- Python 2:
sys.maxintcontains the maximum value a Python int can hold.- On a 64-bit Python 2.7, the size is 24 bytes. Check with
sys.getsizeof().
- On a 64-bit Python 2.7, the size is 24 bytes. Check with
- Python 3:
sys.maxsizecontains the maximum size in bytes a Python int can be.- This will be gigabytes in 32 bits, and exabytes in 64 bits.
- Such a large int would have a value similar to 8 to the power of
sys.maxsize.
2 of 9
25
This PEP should help.
Bottom line is that you really shouldn't have to worry about it in python versions > 2.4
Tutorialspoint
tutorialspoint.com › python › python-long-function.htm
Python long() Function
The long() function from Python 2 has been deprecated in Python 3.
Readthedocs
portingguide.readthedocs.io › en › latest › numbers.html
Numbers — Conservative Python 3 Porting Guide 1.0 documentation
The long builtin no longer exists. In Python 2, calling int on a number that doesn’t fit in the machine int range would automatically create a long with the appropriate value.
Python
docs.python.org › 3 › c-api › long.html
Integer Objects — Python 3.14.7 documentation
All integers are implemented as “long” integer objects of arbitrary size. On error, most PyLong_As* APIs return (return type)-1 which cannot be distinguished from a number. Use PyErr_Occurred() to disambiguate. ... Part of the Limited API (as an opaque struct). This subtype of PyObject represents a Python integer object.
Python Course
python-course.eu › material › course › html › text19.html
Slide 20
Long Integer If an integer literal ends with an l or L, it becomes a Python long integer. It can grow as “long” as needed. Since Python 2.2. the letter “l” or “L” is no longer needed, as integers are automatically converted to long integers on overflow.
Fangohr
fangohr.github.io › blog › performance-of-pythons-long-data-type.html
Performance of Python's long data type — Computational Science and Data Science
Python 2.x has two integer datatypes: the int and the long. (In Python 3.x, the distinction disappears.) The int data type corresponds to the 'normal' integer data type that the CPU supports.
Google Groups
groups.google.com › g › sage-devel › c › mb9tu_bw_yg
int vs long in cython
No, these routines are about the python types. They get used as `type(x) is int` and `type(x) is long`. They are used in a different namespace from `cdef int x` and `cdef long x` and cdef long long x` (well, the `x` is in the cython object namespace. The C-types don't make it into the cython object namespace.
Codementor
codementor.io › community › how python implements super long integers?
How python implements super long integers? | Codementor
January 10, 2020 - Python, in order to keep things efficient implements the Karatsuba algorithm that multiplies two n-digit numbers in O ( nˡᵒᵍ³ ) elementary steps. The algorithm is slightly complicated is out of the scope of this article but you can find its implementation in k_mul and k_lopsided_mul functions in file longobject.c.
GitConnected
levelup.gitconnected.com › how-python-implements-super-long-integers-aabba0c988df
How python implements super long integers? | by Arpit | Medium
January 10, 2020 - An integer in Python is a C struct defined as following · PyObject_VAR_HEAD is a macro that expands into a PyVarObject that has the following structure ... This indicates that an integer, just like a tuple or a list, is variable in length and this is our first insight into how it could support gigantically long integers.
GeeksforGeeks
geeksforgeeks.org › python › what-is-the-maximum-possible-value-of-an-integer-in-python
What is the maximum possible value of an integer in Python ? - GeeksforGeeks
July 23, 2025 - Thus we never need any special arrangement for storing large numbers (Imagine doing above arithmetic in C/C++). As a side note, in Python 3, there is only one type "int" for all type of integers. In Python 2.7. there are two separate types "int" (which is 32 bit) and "long int" that is same as "int" of Python 3.x, i.e., can store arbitrarily large numbers.