You are right that an integer infinity is possible, and that none has been added to the Python standard. This is probably because math.inf supplants it in almost all cases (as Martijn stated in his comment).

In the meantime, I added an implementation of extended integers on PyPI:

In [0]: from numbers import Integral, Real

In [0]: from extended_int import int_inf, ExtendedIntegral, Infinite

In [0]: i = int_inf

In [4]: float(i)
Out[4]: inf

In [5]: print(i)
inf

In [6]: i ** i

Out[6]: inf

In [7]: i
Out[7]: inf

In [9]: isinstance(i, Real)

Out[9]: True

In [10]: isinstance(i, Integral)

Out[10]: False

In [11]: isinstance(i, Infinite)

Out[11]: True

In [12]: isinstance(i, ExtendedIntegral)

Out[12]: True

In [13]: isinstance(2, ExtendedIntegral)

Out[13]: True

In [14]: isinstance(2, Infinite)

Out[14]: False
Answer from Neil G on Stack Overflow
🌐
Python.org
discuss.python.org › ideas
Integer infinity - Ideas - Discussions on Python.org
December 11, 2023 - You could accomplish this by annotating retries: int | float and passing retries=float("inf") or retries=math.inf, but it would be nice if you could just pass int("inf") and not need to change the type annotation.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-infinity
Python infinity (inf) - GeeksforGeeks
As of 2020, there is no such way to represent infinity as an integer in any programming language so far. But in Python, as it is a dynamic language, float values can be used to represent an infinite integer.
Published   July 12, 2025
🌐
Note.nkmk.me
note.nkmk.me › home › python
Infinity (inf) in Python | note.nkmk.me
August 11, 2023 - Any comparison involving nan is always False. print(float('inf') > float('nan')) # False print(float('inf') < float('nan')) # False print(float('inf') == float('nan')) # False ... In Python 3, integers (int) don't have a maximum limit.
🌐
Quora
quora.com › Can-infinite-integers-be-created-in-Python
Can infinite integers be created in Python? - Quora
Floats, however have a notion of infinity and negative infinity and can be used in comparison operations with integers. ... This is a useful trick if one is going through a list of nuumbers in a loop and does comparison, for example if you want to find the lowest number (although min function is faster and more readable th ... No. Python ...
🌐
Flexiple
flexiple.com › python › python-infinity
Python Infinity - All you need to know | Flexiple Tutorials - Flexiple
March 14, 2022 - All arithmetic operations, let ... value will always lead to an infinite number. Infinity is defined as something that has no end, therefore is not represented as an integer....
🌐
STechies
stechies.com › python-infinity
Infinity in Python - Represent an Infinite Number in Python
In Python, there is no way or method to represent infinity as an integer. This matches the fundamental characteristic of many other popular programming languages.
Find elsewhere
🌐
Python Forum
python-forum.io › thread-34889.html
int infinity
Interpreter · IRC · Python Forum · Python Coding · General Coding Help · Thread Rating: 0 Vote(s) - 0 Average · 1 · 2 · 3 · 4 · 5 · Users browsing this thread: 1 Guest(s) View a Printable Version · Powered By MyBB, © 2020 Designed byrain. Forum Stats Contact Us Lite (Archive) Mode ...
🌐
CodeGym
codegym.cc › java blog › learning python › infinity in python: mastering the infinite
Infinity in Python: Mastering the Infinite
August 13, 2024 - In these examples, Python behaves exactly as you’d expect, adhering to the rules of mathematics. Now, here's a twist—what if you want to represent infinity as an integer? Python doesn’t provide a built-in way to represent infinity with integers because integers in Python are arbitrary-precision, meaning they can grow as large as memory allows.
🌐
FavTutor
favtutor.com › blogs › infinity-python
Infinity in Python: How to Represent with Inf? (with Examples)
April 3, 2023 - Python does not have a dedicated infinity sign, but the float('inf') value can be used to symbolize infinite numbers. Whether you're working with integers or floating-point values, this value is universally interchangeable.
🌐
TutorialsPoint
tutorialspoint.com › how-can-i-represent-an-infinite-number-in-python
How can I represent an infinite number in Python?
November 9, 2022 - There is no way to represent infinity as an integer in Python. This is a fundamental feature of several other popular programming languages.
🌐
W3Schools
w3schools.com › python › ref_math_inf.asp
Python math.inf Constant
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... # Import math Library import math # Print the positive infinity print (math.inf) # ...
🌐
Reddit
reddit.com › r/programminglanguages › how stupid is the idea of having infinity included in integer type? more over, how to design a integer/floating point system that makes more sense mathematically?
r/ProgrammingLanguages on Reddit: How stupid is the idea of having infinity included in integer type? More over, how to design a integer/floating point system that makes more sense mathematically?
July 26, 2023 -

So in my imagined language, efficiency is not an issue. I decide to use arbitrary precision integers(i.e. big ints). I realize that sometimes you need infinity as a boundary, so I'm curious, how bad is the idea of having positive/negative infinity in integer type?

I know the fact that you have more UBs, like 0*inf doesn't make sense, but it's fundamentally the same as div by 0 problems. And it should be solved the same as div by 0s.

And for floating numbers, we're all plagued by precision problems, so I think it should make sense for any floating number to be encoded by x = (a, b), where it means that: a - b < x < a + b, and as you do floating point arithemetic, b grows and you lose the precision.

In general, is there any efforts on designing a number system for both integer/floating nums that make more sense mathematically, when you don't care about performance?

EDIT: just realized that haskell have both NAN and INF included in the language.

🌐
Python Central
pythoncentral.io › infinity-in-python-how-to-represent-and-use-infinite-numbers
Infinity In Python: How to Represent (And Use!) Infinite Numbers | Python Central
June 27, 2023 - Now that we know how to represent infinity in Python, let's explore how mathematical operations behave when dealing with infinite values. When performing mathematical operations involving infinity, we can encounter two scenarios: operations with two infinite values and operations with one infinite value and one finite value. int1 = float('inf') int2 = float('-inf') print("Adding two positive infinities:", int1 + int1) print("Adding two negative infinities:", int2 + int2) print("Adding positive and negative infinity:", int1 + int2)
🌐
DEV Community
dev.to › hrishikesh1990 › how-to-represent-an-infinite-number-in-python-2fm2
How to represent an infinite number in Python? - DEV Community
April 18, 2022 - All arithmetic operations, let ... will always lead to an infinite number. ... Infinity is defined as something that has no end, therefore is not represented as an integer....
🌐
Codedamn
codedamn.com › news › python › how-to-represent-infinity-in-python
How to Represent Infinity in Python
June 30, 2023 - Codedamn is sunsetting. Learn more about what this means for you.
🌐
Like Geeks
likegeeks.com › infinity-in-python
Like Geeks - Linux, Server administration, and Python programming
July 6, 2023 - LikeGeeks - Linux, Server administration, Python programming, and web development tutorials.
🌐
DEV Community
dev.to › ashutoshvaidya › infinity-in-python-12m3
Infinity In Python - DEV Community
January 21, 2023 - ... This is the easiest method because we don't need to import any libraries. To accomplish this, use the code snippet below. # Defining a positive infinite integer positive_infinity = float('inf') print('Positive ...
🌐
Scaler
scaler.com › home › topics › how to represent infinity in python?
How to Represent Infinity in Python? - Scaler Topics
May 4, 2023 - But as you can see in the array the maximum number is -1. So the initial value of ans will decide whether we will get the correct answer or not. In the case of finding the maximum number we need our initial ans to be as small as possible, hence we can use infinity in Python to do so.