Python 3

In Python 3, this question doesn't apply. The plain int type is unbounded.

However, you might actually be looking for information about the current interpreter's word size, which will be the same as the machine's word size in most cases. That information is still available in Python 3 as sys.maxsize, which is the maximum value representable by a signed word. Equivalently, it's the size of the largest possible list or in-memory sequence.

Generally, the maximum value representable by an unsigned word will be sys.maxsize * 2 + 1, and the number of bits in a word will be math.log2(sys.maxsize * 2 + 2). See this answer for more information.

Python 2

In Python 2, the maximum value for plain int values is available as sys.maxint:

>>> sys.maxint  # on my system, 2**63-1
9223372036854775807

You can calculate the minimum value with -sys.maxint - 1 as shown in the docs.

Python seamlessly switches from plain to long integers once you exceed this value. So most of the time, you won't need to know it.

Answer from senderle on Stack Overflow
🌐
DataCamp
datacamp.com › tutorial › everything-you-need-to-know-about-pythons-maximum-integer-value
What You Need to Know About Python's Maximum Integer Value | DataCamp
May 6, 2024 - In a 64-bit system, the maximum integer value was (263 - 1), which was equal to 9,223,372,036,854,775,807. In either system, if a number was outside these bounds, the int data type was automatically converted into a long.
Discussions

How do I represent Integer.MAX_VALUE (Java) in Python?
In the original Java program, how does the Integer.MAX_VALUE work? How does it help with the use of minprice later? The program keeps the smallest number it has seen so far in minprice, so that variable has to start out as the largest possible number. If it starts as anything less, the code might report that incorrectly as the smallest number if all the numbers in the list are larger. How can I replace it sensibly in the Python program? You can use math.inf instead. Or a number from the list. More on reddit.com
🌐 r/learnprogramming
7
1
August 3, 2020
Does Python have something similar to MAX_INT / std::numeric_limits<T>::max()} as in C++?
sys.maxsize is often used in place of sys.maxint in python 3. It means something different, but in almost every case would be the same number. More on reddit.com
🌐 r/learnpython
26
17
August 24, 2024
Using iterators to find the index of the min or max value in a list

There's max_by and min_by:

array.iter().enumerate().max_by(|&(_, item)| item)
More on reddit.com
🌐 r/rust
18
11
April 7, 2015
Why is random.randint(0,8) inclusive of the max, but range(0,8) is exclusive?
In other languages, the random range functionality is inclusive on both ends, because it allows expressing the entire range of a given type without exhausting the bounds of that type. For example, in C++ if you wanted any valid positive integer, then you can write std::uniform_int_distribution(0, INT_MAX). If it were not inclusive, you would have to write INT_MAX + 1 which is very problematic because that value can't be expressed as an int, which is a requirement since the constructor takes the same type as the template type, which is int in this example. So it would be impossible to specify the entire range, therefore the range must be inclusive. Such things are irrelevant in Python because integers are unbounded, but Python is probably just copying the interface that people are most comfortable and used to. And Python provides randrange() if you want a version that uses the familiar half-open interval. More on reddit.com
🌐 r/learnpython
14
19
April 16, 2014
🌐
Analytics Vidhya
analyticsvidhya.com › home › mastering python’s maximum integer value
Mastering Python's Maximum Integer Value
July 5, 2024 - Understand how Python handles integers of arbitrary precision. Identify the maximum integer values supported by different Python versions and system architectures.
🌐
Reddit
reddit.com › r/learnprogramming › how do i represent integer.max_value (java) in python?
r/learnprogramming on Reddit: How do I represent Integer.MAX_VALUE (Java) in Python?
August 3, 2020 -

It seems there is no equivalent of Integer.MAX_VALUE in Python, since the integer type is unbounded. The reason I'm looking at a way to represent it is because I found Java code that I want to translate and run in Python. Both programs are attempted solutions to this stock trading problem.

Java code (Line 3):

public class Solution {
    public int maxProfit(int prices[]) {
        int minprice = Integer.MAX_VALUE;
        int maxprofit = 0;
        for (int i = 0; i < prices.length; i++) {
            if (prices[i] < minprice)
                minprice = prices[i];
            else if (prices[i] - minprice > maxprofit)
                maxprofit = prices[i] - minprice;
        }
        return maxprofit;
    }
}

I was able to come up with the code below, which runs but outputs the wrong result. I'm looking for a way to assign the right value to minprice which would lead to the desired output - I put 0 but it's just a filler.

Python code (Line 3):

class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        minprice=0
        maxprofit=0
        l=len(prices)
        for i in range(l):
            if prices[i]<minprice:
                minprice=prices[i]
            elif prices[i]-minprice>maxprofit:
                maxprofit=prices[i]-minprice
        return maxprofit 

My question is:

  • In the original Java program, how does the Integer.MAX_VALUE work? How does it help with the use of minprice later?

  • How can I replace it sensibly in the Python program?

🌐
freeCodeCamp
freecodecamp.org › news › maximum-integer-size-in-python
Int Max in Python – Maximum Integer Size
April 3, 2023 - On the other hand, Python 3 can handle the operation: import sys print(sys.maxsize * 7809356576809509573609874689576897365487536545894358723468) # 72028601076372765770200707816364342373431783018070841859646251155447849538676 · You can perform operation with large integers values in Python without worrying about reaching the max value.
🌐
Python Pool
pythonpool.com › home › blog › python max int | what’s the maximum value of int data type in python
Python Max Int | What's the Maximum Value of int Data Type in Python
December 30, 2023 - In the above example, we can clearly see that if we are using Python 3, then there is no maximum value for the integer. Even after incrementing the sys.maxsize constant by 1, the data type remains of type integer.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Integer (int) Has No Max Limit in Python 3 | note.nkmk.me
January 27, 2024 - The int type in Python 3, equivalent to the long type in Python 2, has no max or min limit. The sys.maxint constant was removed, since there is no longer a limit to the value of integers.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › sys-maxint-in-python
sys.maxint in Python - GeeksforGeeks
May 9, 2025 - In Python 2, sys.maxint refers to the maximum value an integer can hold on a given platform.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-max-function
Python - max() function - GeeksforGeeks
July 15, 2025 - Python3 · integer = 5 string = "geek" max_val = max(integer, string) print(max_val) Output · TypeError: '>' not supported between instances of 'str' and 'int' In this example, max() function is used to find and store the maximum value within ...
🌐
CodeGym
codegym.cc › java blog › learning python › int max or sys.maxint in python
Int Max or sys.maxint in Python
July 29, 2024 - Max Number: sys.maxsize gives the largest practical integer value. Number1: Assigning a value one less than sys.maxsize. Comparison: Checking if number1 is less than max_number. Understanding and using sys.maxsize in Python is useful for various applications where you need a very large integer value.
🌐
Stack Abuse
stackabuse.com › bytes › maximum-and-minimum-values-for-integers-in-python
Maximum and Minimum Values for Integers in Python
September 11, 2023 - But what if we try to assign a really, really large value to an integer? x = 10**100 print(x) # 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 print(type(x)) # <class 'int'> Even with such a large number, Python still treats it as an integer! This is because Python's int type can handle large integers, limited only by the amount of memory available. So you might be wondering why you'd ever need to know the maximum or minimum values of an integer in Python.
🌐
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 - In Python, value of an integer is not restricted by the number of bits and can expand to the limit of the available memory (Sources : this and this). Thus we never need any special arrangement for storing large numbers (Imagine doing above arithmetic in C/C++).
🌐
DEV Community
dev.to › itsmycode › python-max-int-maximum-value-of-int-in-python-3307
Python Max int | Maximum value of int in Python - DEV Community
October 14, 2022 - ** ** Python 3 does not have sys.maxint , and it does not have a maximum integer limit. However, we can use sys.maxsize to get the maximum value of the Py_ssize_t type in Python 2 and 3.
🌐
Codingem
codingem.com › home › python maximum/minimum integer value (with examples)
Python Maximum/Minimum Integer Value (with Examples)
December 8, 2022 - Even though there’s no limit to how big an integer can be in Python, the sys.maxsize gives you the upper bound for practical lists or strings. The maximum value works as a sentinel value in algorithms, so even though it’s not a hard limit in Python integers, it indicates the maximum word size used to represent integers behind the scenes.
🌐
Its Linux FOSS
itslinuxfoss.com › home › python › how to get max int in python?
How to Get Max Int in Python? – Its Linux FOSS
February 26, 2023 - The maximum value represented by an integer in Python is known as “Max Int”. For example, the “2^31-1” for a 32-bit system and “2^63-1” for a 64-bit system is the maximum integer value for “32” and “64” bit integers.
🌐
Delft Stack
delftstack.com › home › howto › python › python max int
Max Int in Python | Delft Stack
March 11, 2025 - Essentially, there are two types of integers: int and long. The int type is limited to a maximum value of 2,147,483,647 (for a 32-bit system) or 9,223,372,036,854,775,807 (for a 64-bit system).
🌐
Baeldung
baeldung.com › home › core concepts › programming › maximum value of an integer: java vs c vs python
Maximum Value of an Integer: Java vs C vs Python | Baeldung on Computer Science
March 18, 2024 - So, in terms of programming language, this question doesn’t apply at all for Python, cause the plain integer type is, theoretically unbounded. What is not unbounded is the current interpreter’s word size, which is the same as the machine’s word size in most cases. That information is available in Python as sys.maxsize, and it’s the size of the largest possible list or in-memory sequence, which corresponds to the maximum value representable by a signed word.
🌐
W3Resource
w3resource.com › python-interview › what-is-the-maximum-and-minimum-value-for-an-int-float-and-string-data-type-in-python.php
Exploring data type limits in Python
August 12, 2023 - Maximum and minimum values for integer and float data types: Max Int: 9223372036854775807 Min Int: -9223372036854775808 Max Float: 1.7976931348623157e+308 Min Float: 2.2250738585072014e-308 Note: The values provided by sys.maxsize and sys.float_info ...
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › max() function in python: syntax, parameters, and examples
max() Function in Python: Syntax, Parameters & Examples
4 days ago - Each example shows a different use case, so you can see how the max function in Python behaves with numbers, strings, iterables, and empty values. This is the most direct use of max() in Python. You can pass a list of integers, and it will return the largest number.
🌐
Quora
quora.com › What-is-the-highest-number-you-can-have-in-Python
What is the highest number you can have in Python? - Quora
Python doesn’t have a limit to the size of integers, so the so the largest number you can have is, in theory, limited only by how much memory your computer has to store it. On any modern system, this is an unimaginably large number. Python floats are implemented as C doubles, which have a maximum value of 21023