NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #3269 most downloaded on PyPI
Python data structure and operations for intervals
Last release 5 days ago
29 Sep 2026
Ships fairly regularly
a new release about every 5 months
Nearly every release is documented
notes for 21 of 22 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
23 releases · first in 2020
One column per quarter.
IntervalDict.update and __init__ behave like dict.update when the provided intervals overlap (the last provided value wins).
IntervalDict.update and __init__ behave like dict.update when the provided intervals overlap (the last provided value wins).IntervalDict.pop accepts None as default value.from_string accepting prefix (re.match) instead of full value (re.fullmatch) for infinities.iterate explicitly states that base should be side-effect-free.Drop official support for Python 3.9 (EoL).
Interval creation and union for large disjunctions of overlapping intervals.Interval.__contains__ for values.Interval.overlaps, __and__, and __contains__ for large, complex intervals when applied to small subintervals (see #107, Henry Tung).IntervalDict.update and IntervalDict constructor for hashable values (see #108).A __version__ attribute relying on importlib.metadata.
__version__ attribute relying on importlib.metadata.uv.lock lock-file for reproducible builds.black to ruff for code style.pyproject.toml-based project.pyproject.toml).dev dependency group (PEP 735).setuptools to hatchling for building portion.coverage to pytest-cov for test coverage.The how function of combine can access the current interval if pass_interval is set (see #97 ).
how function of combine can access the current interval if pass_interval is set (see #97).The combine method of an IntervalDict accepts a missing parameter to fill values for non-overlapping keys (see #96 ).
Fixes import error in create_api for Python 3.10+ (see #87 )
Fixes import error in create_api for Python 3.10+ (see #87)
create_api in Python 3.10+ (see #87).Fix import error when using create_api outside a REPL (see #85 ).
Fix import error when using create_api outside a REPL (see #85).
An AbstractDiscreteInterval class to ease the creation of specialized discrete intervals (experimental).
AbstractDiscreteInterval class to ease the creation of specialized discrete intervals (experimental).create_api function to generate an API similar to the one of portion but configured to use a given subclass of Interval (experimental, see Specialize & customize intervals).repr and to_string for Interval instances (see #76, adm271828).from_string and from_data accepts a klass parameter to specify which class should be used to create Interval instances (default is Interval).klass parameter for open, closed, openclosed, closedopen, singleton and empty (default is Interval)._klass class attribute in IntervalDict to specify how to create Interval instances (default is Interval).IntervalDict uses self.__class__ to preserve subclasses when creating new instances.Speed up lookups in IntervalDict for non-interval keys.
IntervalDict for non-interval keys.iterate by no longer creating singleton instances under the hood.Interval is compared using > with an Interval instance (see #75).Comparing an interval and a value is deprecated since it is ill-defined when the value is on the left of <= or >= . Convert values to singletons first…
IntervalDict.as_dict has an optional atomic=False parameter that, if set to True, returns intervals that are atomic.left, lower, upper and right).list(P.empty()) == [], i.e., the empty interval is a disjunction of no interval (see #72).<, >, <=, nor >= when compared to another interval.<= or >=. Convert values to singletons first.Deprecate and move mergeable function to Interval._mergeable class method;
Interval(see #58):
self.__class__ instead of Interval to create new instances;mergeable function to Interval._mergeable class method;Interval.from_atomic is now a class method instead of a static method.IntervalDict (#65, Jeff Trull).IntervalDict..overlaps and .contains for non-overlapping intervals/items.Drop official support for Python 3.5.
black as official code formatting.from_stringraises a ValueError if given string cannot be parsed to an interval (#57).Getting items from an Interval using a slice does no longer return a list but an Interval instance.
Interval using a slice does no longer return a list but an Interval instance.pandas (#54).Much faster get, copy and | operations for IntervalDict.
get, copy and | operations for IntervalDict.Nothing published for this version
Empty intervals are contained in all intervals (#41).
IntervalDict supports | and |=, the same way dict will do starting from Python 3.9 (#37).
IntervalDict supports | and |=, the same way dict will do starting from Python 3.9 (#37).Fix a regression introduced in 2.1.0 for IntervalDict (#36).
IntervalDict (#36).IntervalDict.as_dict() to export its content to a classical Python dict.
IntervalDict.as_dict() to export its content to a classical Python dict.IntervalDict.keys(), values() and items() return view objects instead of lists.IntervalDict.popitem() now returns a (key, value) pair instead of an IntervalDict.IntervalDict.pop() now correctly states that the value (and not the key)
is returned.Fix occasional StopIteration exception when checking for containment (#28).
StopIteration exception when checking for containment (#28).Fix invalid representations of non-atomic intervals composed of a singleton (#22).
(breaking) Remove deprecated permissive in i.overlaps.
i.empty to check for interval emptiness.i.atomic to check for interval atomicity.adjacent method to test whether two intervals are adjacent.i.__getitem__ supports slices.Interval.from_atomic(left, lower, upper, right) to create an interval composed of a single atomic interval (replaces AtomicInterval(left, lower, upper, right)).python-intervals has been renamed portion.from_string and to_string: bound, disj, sep, left_open, left_closed, right_open, right_closed, pinf and ninf;from_data and to_data: pinf and ninf;iterate: base and reverse;Interval.replace: ignore_inf.incr is replaced by step in iterate.range, the step parameter in iterate is always added even if reverse=True.i.enclosure is a property and no longer a method.Interval returns Interval instances instead of AtomicInterval ones.CLOSED and OPEN are members of the Bound enumeration.AtomicInterval and all its operations in Interval.AtomicInterval is a namedtuple and is no longer part of the public API.i.to_atomic() (use i.enclosure instead).i.is_empty() (use i.empty instead).i.is_atomic() (use i.atomic instead).CLOSED and OPEN do no longer define an implicit Boolean value. Use ~ instead of not to invert a bound.permissive in i.overlaps.adjacent in i.overlaps, use i.adjacent method instead.Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →