python-ranges
Continuous Range, RangeSet, and RangeDict data structures
What it is and what it does
python-ranges fills a gap in Python's standard library by providing proper continuous range data structures. The built-in range() only works with integers and doesn't support continuous values like floats or dates. This package introduces Range (a single continuous interval), RangeSet (a collection of non-overlapping ranges), and RangeDict (a dictionary that uses ranges as keys). These structures let you replace verbose if/elif/else chains and boundary-checking logic with cleaner, more readable code. For example, instead of writing multiple conditional branches to determine which tax bracket an income falls into, you can use a RangeDict to map income ranges directly to tax calculations.
The Range class supports any comparable data type—numbers, strings, dates—and can represent bounded or unbounded intervals with inclusive or exclusive endpoints. RangeSet provides set-like operations (union, intersection, difference) on collections of ranges. The package has zero runtime dependencies and installs easily, but development has stalled since early 2023, so it receives no active maintenance or updates.
Use it for:
- Implement tax bracket or tiered pricing logic by mapping income or price ranges to corresponding rates or fees.
- Validate user input by checking if a value falls within acceptable bounds using membership testing.
- Clamp numeric or comparable values to a range without verbose min/max nesting.
- Build interval-based queries or lookups where you need to find which range a value belongs to.
- Perform set operations on date ranges, version ranges, or other comparable intervals.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Range, RangeSet, and RangeDict data structures for representing continuous and non-continuous ranges of values, and for using ranges as dictionary keys.
Yes, if you need range data structures and can accept abandoned maintenance. The package is stable, has no known vulnerabilities, and solves a real problem with clean syntax. However, do not rely on it for active bug fixes or compatibility updates beyond Python 3.9. It is suitable for self-contained projects where you control the Python version and can tolerate no future support.
Install
python-ranges on PyPI
pip
pip install python-rangesuv
uv add python-rangespoetry
poetry add python-rangesInstalling python-ranges
Before you install
Low install friction with no runtime dependencies. However, the project is abandoned—last commit was 2023-07-25 and no releases since 2023-02-15. Requires Python 3.9 or higher.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install python-ranges
from ranges import Range, RangeDict
# Check membership
if 5 in Range(1, 10):
print("Value in range")
# Use ranges as dictionary keys
tax_brackets = RangeDict({
Range(0, 9701): 0.10,
Range(9701, 39476): 0.12,
})
rate = tax_brackets[15000]
Requires Python 3.9 or higher.
Verify before relying
- Whether the package handles edge cases with non-numeric types (strings, dates) as thoroughly as the description suggests.
- Performance characteristics when working with very large ranges or RangeSets.
- Compatibility with Python versions after 3.9, given the abandoned maintenance status.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 1,276 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 77,689/month — #14,505 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_ranges-1.2.2-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
intervalsProvides Python classes for representing and…
permissive · top 15,000 on PyPI
infinityProvides an Infinity class that can be compared…
permissive · top 15,000 on PyPI
portionportion provides data structures and operations…
copyleft · top 5,000 on PyPI
pricesHandles monetary amounts with currency…
permissive · top 15,000 on PyPI
uszipcodeProvides programmable access to a database of…
permissive · top 5,000 on PyPI
multisetProvides a mutable and immutable multiset data…
permissive · top 15,000 on PyPI
orderly-setProvides multiple ordered set implementations…
permissive · top 1,000 on PyPI
python-stdnumParses, validates, and reformats standard…
copyleft · top 5,000 on PyPI
pipePipe enables shell-like infix syntax for…
permissive · top 15,000 on PyPI
pyxlsxProvides dictionary-like read and write access…
permissive · top 15,000 on PyPI