Registry / serialization / infinity

infinity

JSON →
library1.5pypypi✓ verified 84d ago

The `infinity` library for Python provides a universal, all-in-one infinity value (`inf`) that can be compared to any other object, including numbers, lists, strings, and custom types, offering more flexible comparison behavior than `float('inf')`. It is currently at version 1.5 and has an infrequent release cadence for its stable feature set, reflecting its simple and focused utility.

pip install infinity
INSTALL
IMPORT
SIG · INFINITY
I
infinity
serializationpythonv1.5
Install
2.5s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.5s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

inf
from infinity import inf
import infinity; my_inf = infinity.Infinity()
The 'inf' object is a singleton and should be imported directly, not instantiated.

Demonstrates importing `inf` and its universal comparison capabilities with various data types, including numbers, strings, and collections, as well as accessing negative infinity.

from infinity import inf # Universal comparison print(f"inf > 1000: {inf > 1000}") print(f"inf < 1000: {inf < 1000}") print(f"inf == float('inf'): {inf == float('inf')}") # Compare with non-numeric types (unique feature of infinity.inf) print(f"inf > 'hello': {inf > 'hello'}") print(f"inf > []: {inf > []}") print(f"inf > {'a': 1}: {inf > {'a': 1}}") # Using negative infinity neg_inf = -inf print(f"neg_inf < -1000: {neg_inf < -1000}")
Debug
Known issues
gotchaDo not confuse `infinity.inf` with `float('inf')` or `math.inf`. While `infinity.inf` is equal to `float('inf')`, it offers enhanced comparison capabilities against non-numeric types that standard Python floats do not support.
fix
Use `from infinity import inf` when you need to compare against arbitrary Python objects. Use `float('inf')` or `math.inf` for strictly numerical infinity within mathematical contexts.
affects: All versions (1.x)
gotcha`infinity.inf` is implemented as a singleton object. There is only one instance of `inf` and `-inf`. You should not attempt to create new instances or modify its state.
fix
Always import `inf` directly via `from infinity import inf` and use it as is. Do not try to call `infinity.Infinity()` or similar constructs.
affects: All versions (1.x)
gotchaWhile `infinity.inf` handles comparisons broadly, its interaction with `float('nan')` (Not a Number) can be inconsistent due to `NaN`'s unique comparison rules (e.g., `NaN == NaN` is False). Comparing `inf` with `NaN` might not always yield intuitive results.
fix
If your data might contain `NaN` values, explicitly check for `math.isnan()` before performing comparisons with `infinity.inf` to ensure your logic handles `NaN` as intended.
affects: All versions (1.x)
Errors
Common errors & fixes
NameError: name 'inf' is not defined
The `inf` object was not correctly imported from the `infinity` library.
fix
Add `from infinity import inf` at the top of your Python script or module where you intend to use `inf`.
AttributeError: module 'infinity' has no attribute 'Infinity'
Attempting to instantiate a class named `Infinity` (e.g., `infinity.Infinity()`) instead of using the pre-defined singleton `inf`.
fix
The `inf` object is a singleton and should be imported and used directly: `from infinity import inf; my_val = inf`.
TypeError: '<' not supported between instances of 'float' and 'str'
You are likely using `float('inf')` or `math.inf` for comparison against a non-numeric type (e.g., string, list). Standard Python floats do not support such comparisons.
fix
Switch to `infinity.inf` for universal comparisons across different data types. Ensure you have `from infinity import inf` and use `inf` for these broader comparisons.
Upgrade
Version history
1.5latest on PyPI · released Jun 3, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Resources
infinity — pip install infinity · libregistry