intervals
Python tools for handling intervals (ranges of comparable objects).
What it is and what it does
intervals is a Python library for creating and working with mathematical intervals—ranges defined by lower and upper bounds with configurable inclusion rules. It supports multiple interval types (IntInterval, FloatInterval, DateInterval, DateTimeInterval, etc.) and allows you to define open intervals (excluding endpoints), closed intervals (including both), or half-open variants. You can initialize intervals via factory methods like closed(), open_closed(), or from string representations like '[1, 5]' or '1 - 5'.
The library provides properties to query interval characteristics (length, radius, centre, whether it's degenerate or empty) and supports standard operations like containment checks and comparisons. Its single runtime dependency is infinity, a lightweight package for representing infinite bounds. The package is pure Python and installs with low friction, but has been abandoned since mid-2022, so it receives no maintenance or updates.
Use it for:
- Represent and validate time ranges or scheduling windows to check if a date falls within a booking or availability interval.
- Define numeric ranges for data validation, filtering, or binning—for example, categorizing sensor readings into interval buckets.
- Build interval trees or perform range queries to test membership, overlap, or containment of comparable values.
- Parse and manipulate human-readable interval notation from configuration files or user input using from_string.
- Model mathematical or scientific computations involving bounded domains, such as function domains or parameter ranges.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python classes for representing and manipulating intervals (ranges) of comparable objects with support for open, closed, and half-open bounds, and operations like intersection and containment checking.
Yes, if you need straightforward interval arithmetic and can accept an unmaintained package. The library is stable for its core use case and has no known vulnerabilities. However, do not adopt it for new projects requiring long-term support or compatibility with future Python versions—the last commit was 2022-05-05 and no maintenance is expected. Suitable for legacy codebases or internal tools where you control the Python version.
Install
intervals on PyPI
pip
pip install intervalsuv
uv add intervalspoetry
poetry add intervalsInstalling intervals
Before you install
Low install friction with a pure-Python wheel. However, the package is abandoned—last commit was 2022-05-05 and no releases since 2021-07-02. While it has 108 repository stars, the lack of maintenance means bug fixes and compatibility updates are unlikely.
License in practice
BSD license is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute the package freely provided you include the license notice.
Quickstart
pip install intervals
from intervals import IntInterval
interval = IntInterval.closed(1, 5)
print(interval.lower, interval.upper)
Verify before relying
- Whether the package works reliably with Python versions released after 2022 (last commit date).
- Current compatibility with modern versions of the infinity dependency.
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — infinity |
| Maintenance | abandoned — 1,869 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 245,244/month — #8,737 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: intervals-0.9.2-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 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
python-rangesProvides Range, RangeSet, and RangeDict data…
permissive · top 15,000 on PyPI
intervaltreeA self-balancing interval tree data structure…
permissive · top 5,000 on PyPI
igwn-segmentsProvides segment, segmentlist, and…
copyleft · top 15,000 on PyPI
nclsNCLS provides a fast interval overlap query…
permissive · top 15,000 on PyPI
pyrangesPyRanges provides efficient querying and…
permissive · top 15,000 on PyPI
pyiotoolsProvides unified I/O handling for command-line,…
permissive · top 15,000 on PyPI
MAPIEMAPIE computes prediction intervals and…
permissive · top 15,000 on PyPI
DateTimeRangeDateTimeRange creates and manipulates time…
permissive · top 15,000 on PyPI