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.maxint contains the maximum value a Python int can hold.
    • On a 64-bit Python 2.7, the size is 24 bytes. Check with sys.getsizeof().
  • Python 3: sys.maxsize contains 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.
Answer from Ignacio Vazquez-Abrams on Stack Overflow
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ builtins โ€บ stdtypes.html
Built-in Types โ€” Python 3.14.7 documentation
The constructors int(), float(), and complex() can be used to produce numbers of a specific type. Python fully supports mixed arithmetic: when a binary arithmetic operator has operands of different built-in numeric types, the operand with the โ€œnarrowerโ€ type is widened to that of the other:
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_int.asp
Python int() Function
The int() function converts the specified value into an integer number. ... Coding fundamentals as bite-sized lessons and challenges. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: ...
Discussions

integer - Can you explain how int function(int()) works in Python? - Stack Overflow
Hello I just have a question about int function. It convert data(for example, string) to int data. My question is how this function works like this? I tried to implement int function myself without... More on stackoverflow.com
๐ŸŒ stackoverflow.com
integer - How does Python manage int and long? - Stack Overflow
Does anybody know how Python manage internally int and long types? Does it choose the right type dynamically? What is the limit for an int? I am using Python 2.6, Is is different with previous ve... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How much memory do int's take up in python?
In Python, integers have arbitrary magnitude. You need not worry about how many bits are used in memory to store the integer; integers can be arbitrarily large (or large negative). In this case, the 224 bits you are seeing are not all used to represent the integer; a lot of that is overhead of representing a Python object (as opposed to a native value in C-like languages). EDIT: See also: https://docs.python.org/3/library/stdtypes.html#typesnumeric More on reddit.com
๐ŸŒ r/learnpython
11
4
December 6, 2014
What does Int() mean?
It tries to convert the input into an integer type value More on reddit.com
๐ŸŒ r/learnpython
10
2
November 7, 2019
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ builtins โ€บ functions.html
Built-in Functions โ€” Python 3.14.7 documentation
If the argument is a number, the constructor serves as a numeric conversion like int and float. For a general Python object x, complex(x) delegates to x.__complex__(). If __complex__() is not defined then it falls back to __float__().
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-int-function
Python int() Function - GeeksforGeeks
September 26, 2025 - The Python int() function converts a given object to an integer or converts a decimal (floating-point) number to its integer part by truncating the fractional part.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 79417379 โ€บ can-you-explain-how-int-functionint-works-in-python
integer - Can you explain how int function(int()) works in Python? - Stack Overflow
It really depends what you want your int() function to be able to accept as input. ... You start as simple as '123' --> 100*1 + 10*2 + 3. Then optimize and generalize to end like this. Yes, coding is hard, good that you realized that. ... Share a small sample code of what you are trying to do for others to understand easily and help you.Thx ... Save this answer. ... Show activity on this post. Pythons int() function does more than just converting a string to integer.The behavior varies based on the argument and an optional base parameter.
๐ŸŒ
Python Reference
python-reference.readthedocs.io โ€บ en โ€บ latest โ€บ docs โ€บ ints
int โ€” Python Reference (The Right Way) 0.1 documentation
Numbers are created by numeric literals or as the result of built-in functions and operators. Unadorned integer literals (including binary, hex, and octal numbers) yield plain integers unless the value they denote is too large to be represented as a plain integer, in which case they yield a long integer.
Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ @tuenguyends โ€บ pythons-integer-int-type-b671705e8339
Pythonโ€™s integer (int) type | by Tue Nguyen | Medium
April 15, 2022 - Pythonโ€™s integer (int) type Python uses int to represent integers (or whole numbers) such as 10, 100, or -30. Create an integer We can create an int variable through an assignment with an integer โ€ฆ
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ integer
Mimo: The coding platform you need to learn Web Development, Python, and more.
Integer, or int, is a data type in Python that represents whole numbers without a decimal point.
๐ŸŒ
YouTube
youtube.com โ€บ practical coding
How to use int function in Python | Python functions made easy - YouTube
In this beginner's Python tutorial, you will learn how to convert a string to an integer in Python. To do so, you will learn how to use the int() function th...
Published: July 9, 2020
Views: 4K
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how much memory do int's take up in python?
r/learnpython on Reddit: How much memory do int's take up in python?
December 6, 2014 -

Going through the docs I didn't find a definite answer

If I do

x = 234234
sys.getsizeof(x)

It returns 28, so that's 224 bits ?

Apparently getsizeof() returns the size of an object in bytes, is this size consistent across all int's in python though?

I know that there are long ints, and that they are converted automatically to long ints at a certain value in python, but I'm just wondering about ints for now.

In Java the size that I got was 32 bit, so 4 bytes.

Is this correct, that :

python int = 224 bits

java int = 32 bits

And is this because the python int has more methods etc?

Basically what I was trying to state was that across programming languages the data type sizes were fairly conventional and that an int in C# would be the same size as an int in Python / Java. I think this might be wrong though.

Thanks!

Top answer
1 of 4
4
In Python, integers have arbitrary magnitude. You need not worry about how many bits are used in memory to store the integer; integers can be arbitrarily large (or large negative). In this case, the 224 bits you are seeing are not all used to represent the integer; a lot of that is overhead of representing a Python object (as opposed to a native value in C-like languages). EDIT: See also: https://docs.python.org/3/library/stdtypes.html#typesnumeric
2 of 4
3
is this because the python int has more methods etc? Almost but not quite. Internally, all python objects contain at least a reference count used by the garbage collector and a pointer to a [statically-allocated] type object (which is essentially an array of function pointers to the methods available on objects of that type). Objects with variable size (like lists, dicts, and python 3's variable-precision ints) also contain a size value. So that's 3 values stored in the "header" of each python object. On a 32-bit platform these 3 values will most likely take 3*32 bits, and on a 64-bit platform they will take 3*64 bits. So any variable-size python object with zero size is going to take at least 24 bytes on a 64-bit machine. Beyond that, the value of a python long integer is actually stored in an array of 15- or 30-bit chunks (depending on your build). On my 64-bit build, you can see the size of integers increase steadily as I increase their size by increments of 30 bits. >>> [sys.getsizeof(2**(n*30) - 1) for n in range(100)] [24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 248, 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320, 324, 328, 332, 336, 340, 344, 348, 352, 356, 360, 364, 368, 372, 376, 380, 384, 388, 392, 396, 400, 404, 408, 412, 416, 420] And there you have it, demystified I hope.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to use int() and str() properly
r/learnpython on Reddit: how to use int() and str() properly
February 16, 2024 -

good day everyone,

would anyone be able to help me figure out how to make a function to calculate a size for a circle and increase it's size by a multiple of 2,3,4 and so on with retaining it's original quotient value?

i would have a default ellipse right in the middle of the canvas with a size of 10,10

i need help to make a function to increase that size by pressing key 2 and multiply it and so on with key 3, key 4.....

i just couldnt get around how to use int() and str() properly

๐ŸŒ
Kansas State University
textbooks.cs.ksu.edu โ€บ intro-python โ€บ 02-numbers โ€บ 01-integers
Integers :: Introduction to Python
July 30, 2026 - In Python, there is effectively no maximum size for an integer, so we can store any arbitrarily large whole number (either positive or negative) in an int variable.
Top answer
1 of 4
21

It does exactly what it says - converts a string to integer in a given numeric base. As per the documentation, int() can convert strings in any base from 2 up to 36. On the low end, base 2 is the lowest useful system; base 1 would only have "0" as a symbol, which is pretty useless for counting. On the high end, 36 is chosen arbitrarily because we use symbols from "0123456789abcdefghijklmnopqrstuvwxyz" (10 digits + 26 characters) - you could continue with more symbols, but it is not really clear what to use after z.

"Normal" math is base-10 (uses symbols "0123456789"):

int("123", 10)  # == 1*(10**2) + 2*(10**1) + 3*(10**0) == 123

Binary is base-2 (uses symbols "01"):

int("101", 2)   # == 1*(2**2) + 0*(2**1) + 1*(2**0) == 5

"3" makes no sense in base 2; it only uses symbols "0" and "1", "3" is an invalid symbol (it's kind of like trying to book an appointment for the 34th of January).

int("333", 4)   # == 3*(4**2) + 3*(4**1) + 3*(4**0)
                # == 3*16 + 3*4 + 3*1
                # == 48 + 12 + 3
                # == 63
2 of 4
7

The base value tells python to interpret the given string to be a value of a different base.

For example, the 1011 in base 2 is 11. Thus, int('1011', 2) returns 11.
On the other hand, 1011 in base 3 is 31. Thus, int('1011', 3) returns 31.

Decimals are in base 10, which is why the default value of base is 10.

A fun side-effect of choosing a numeric base, is that there does not exist a digit in that system that is higher than (or equal to) the base itself. This is why we do not have a digit for ten in the decimal system, while the hexadecimal system (base 16) uses the digit A for ten. This is why you were getting errors for asking a number with the digit 5 to be interpreted in base 4.

๐ŸŒ
Real Python
realpython.com โ€บ ref โ€บ builtin-types โ€บ int
int | Pythonโ€™s Built-in Data Types โ€“ Real Python
The built-in int data type represents integer numbers, which are whole numbers without any decimal places. Integers can be positive, negative, or zero.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_numbers.asp
Python Numbers
Note: You cannot convert complex numbers into another number type. Python does not have a random() function to make a random number, but Python has a built-in module called random that can be used to make random numbers:
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ built-in โ€บ int
Python int() (With Examples)
Online Python Online JavaScript Online SQL Online Java Online HTML Online C Online C++ Online C# Online PHP Online Swift Online Kotlin Online TypeScript Online Go Online Rust Online Scala Online Dart Online R Online Ruby ... The int() function converts a number or a string to its equivalent integer.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_int.asp
Python Int
Python Functions Python Arguments Python *args / **kwargs Python Scope Python Decorators Python Lambda Python Recursion Python Generators Code Challenge Python Range ... Matplotlib Intro Matplotlib Get Started Matplotlib Pyplot Matplotlib Plotting Matplotlib Markers Matplotlib Line Matplotlib Labels Matplotlib Grid Matplotlib Subplot Matplotlib Scatter Matplotlib Bars Matplotlib Histograms Matplotlib Pie Charts