Is there some pre-defined constant like INT_MAX
?
CARVIEW |
Select Language
HTTP/2 301
date: Sun, 27 Jul 2025 17:12:53 GMT
content-length: 0
location: /questions/4581842/is-there-a-way-to-get-the-largest-integer-one-can-use-in-python
cf-ray: 965dc3a6fe26c1a4-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=11b45d70-ef83-4fa9-a6b8-1200b003b292; expires=Mon, 27 Jul 2026 17:12:53 GMT; domain=.stackoverflow.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
feature-policy: microphone 'none'; speaker 'none'
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: 3dc7b058-bdff-418f-9eda-df4b2d32cda6
x-worker-origin-response-time: 261000000
vary: Accept-Encoding
x-dns-prefetch-control: off
set-cookie: __cflb=02DiuFA7zZL3enAQJD3AX8ZzvyzLcaG7uvDp7y6p9qedA; SameSite=Lax; path=/; expires=Mon, 28-Jul-25 16:12:53 GMT; HttpOnly
set-cookie: prov=11b45d70-ef83-4fa9-a6b8-1200b003b292; Path=/; HttpOnly; Domain=stackoverflow.com
set-cookie: __cf_bm=mQYno7vgLI1AoBhSrugJZaA.Qv4Ao34F_nzZStrxuN4-1753636373-1.0.1.1-V8_s2l4HPH9v3ixMK4JXvofgr7_QZLek2ufJY0zjNDqtx1uHiiVTzoQVWUPWH4sTt0r3QDRgaonWs4WoBiCaF6kLV8XE9GL6PWz9I28cmjc; path=/; expires=Sun, 27-Jul-25 17:42:53 GMT; domain=.stackoverflow.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=eEIEv38dSpFuAUl5Of1Q9NKlkTGLVDHHBn91glZqlf0-1753636373871-0.0.1.1-604800000; path=/; domain=.stackoverflow.com; HttpOnly; Secure; SameSite=None
server: cloudflare
HTTP/2 200
date: Sun, 27 Jul 2025 17:12:54 GMT
content-type: text/html; charset=utf-8
cf-ray: 965dc3a8bef0c1a4-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=11b45d70-ef83-4fa9-a6b8-1200b003b292; expires=Mon, 27 Jul 2026 17:12:54 GMT; domain=.stackoverflow.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
vary: Accept-Encoding
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
feature-policy: microphone 'none'; speaker 'none'
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: d7d15119-34d9-4ea5-b255-d2a07003b877
x-worker-origin-response-time: 281000000
x-dns-prefetch-control: off
server: cloudflare
content-encoding: gzip
Is there a way to get the largest integer one can use in Python? - Stack Overflow
Skip to main content
Stack Overflow
1
4
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Advertising Reach devs & technologists worldwide about your product, service or employer brand
- Knowledge Solutions Data licensing offering for businesses to build and improve AI tools and models
- Labs The future of collective knowledge sharing
- About the company Visit the blog
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams-
It is 2^31 - 1 in Python 32 and 2^63 - 1 Python 64 bit runtime system.– Vlad BezdenCommented Feb 11, 2020 at 12:15
Add a comment
|
1 Answer 1
Python has arbitrary precision integers so there is no true fixed maximum. You're only limited by available memory.
In Python 2, there are two types, int
and long
. int
s use a C type, while long
s are arbitrary precision. You can use sys.maxint
to find the maximum int
. But int
s are automatically promoted to long
, so you usually don't need to worry about it:
sys.maxint + 1
works fine and returns a long
.
sys.maxint
does not even exist in Python 3, since int
and long
were unified into a single arbitrary precision int
type.
answered Jan 3, 2011 at 3:14
-
31Note that in Python 3 (and Python 2.6 and up)
sys.maxsize
can be used when you need an arbitrarily-large value.– mattdmCommented Jan 23, 2012 at 19:07 -
1
-
1
sys.maxsize
continues to be the theoretical limit on size of containers for python 2 and 3 (theoretical because memory is the real limiting factor) Commented Mar 11, 2017 at 21:14 -
3
- The Overflow Blog
-
-
- Featured on Meta
-
-
-
-
-
Linked
Related
Hot Network Questions
- Is there any verse which says that throughout the Vedas the praise of Shiva is sung?
- Automatic drawing of polygon around selected polygons in QGIS
- Did Denmark report that 64% Palestinian refugees from 1992 received serious fines or jail time?
- In Fantastic Four 2025 shouldn't this thing have taken years?
- Not being introduced to the team – should I ask for it?
- Meaning of 芭蕉 in Tang age
- Will this work as an XOR gate?
- In Jurassic Park, is the lysine dependency intentionally fake (in-universe)?
- Anonymizing a submission for double-blind review
- Still learning electronics, can you explain this voltage protector failure?
- Time Machine backup disk not writeable any longer
- Why aren't there baleen whales at about the size of a dolphin?
- How to navigate in the Universe's Heat Death
- Statistics – Linear Inference – What is the moment generating function of non-central t-distribution?
- How to extend an MDF shelf?
- Is there such a thing as 'aerospace grade software'?
- Extensions of diagonalizable, respectively multiplicative-type, groups
- What is the weight of holy water?
- I don't understand Photos Library.photoslibrary
- Story that taught cryptography in the form of a manga
- Alternative to tedious assert-rewrite for trivial operations?
- Heretofore I think I have been using 'heretofore' incorrectly
- Has the Silver Surfer's clothing (or lack thereof) ever been addressed in the comics?
- How can my dwarves keep humans from reverse engineering their technology?
lang-py