$npx skillfedfor your agent

intervaltree

Editable interval tree data structure for Python 2 and 3

Worth itPyPI LibrariesReleased Dec 20256.3M downloads / moApache-2.0Pure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — intervaltree-3.2.1-py2.py3-none-any.whl
v3.2.1 · released 2025-12-24 · Python !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7.18 · 1 runtime deps: sortedcontainers

Yes. intervaltree is a stable, well-maintained library with low install friction, permissive licensing, no known vulnerabilities, and a focused, proven API for a common data structure problem. Install it if you need to store and query overlapping or enveloped ranges; the self-balancing design and rich query interface make it significantly easier than building your own tree.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low install friction with a single pure-Python runtime dependency (sortedcontainers).
  • The package is in production-stable status and has been actively maintained, with the latest release in 2025 and repository last commit in 2025.
  • Supports Python 2.7 and 3.5 through 3.14.

License · maintenance · safety

Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), allowing commercial use, modification, and distribution with minimal restrictions—suitable for most projects.

last release 2025-12-24 (233 days) · last repo commit 2025-12-25 · 691 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,271,448 downloads/mo, #1,942 on PyPI

Verify before relying

pip install intervaltree

from intervaltree import Interval, IntervalTree

t = IntervalTree()
t[1:5] = "data"
result = sorted(t.overlap(2, 4))
print(result)
  • Whether the package's AVL balancing guarantees specific query performance characteristics (e.g., O(log n) lookups) under typical usage patterns.
  • Real-world performance comparison with alternative interval tree implementations for large datasets.
Same gist for agents: .md · .json

What it is and what it does

intervaltree is a mutable, self-balancing interval tree for Python that stores ranges (intervals) and allows efficient queries by point, by range overlap, or by range envelopment. It was designed to support tagging text and time intervals, where intervals include the lower bound but exclude the upper bound. The package provides a rich API for insertion, deletion, and querying, as well as set-like operations (union, difference, intersection) and restructuring methods (merge, chop, slice).

The tree automatically maintains balance using AVL rebalancing, so you can add and remove intervals without manually managing the structure. It depends only on sortedcontainers for its underlying sorted storage, keeping the dependency footprint minimal. The library supports both Python 2.7 and modern Python versions (3.5 through 3.14), making it suitable for legacy and current codebases alike.

Use it for

  • Tag text spans or time intervals in documents or logs, then query which tags overlap a given point or range.
  • Store scheduling or calendar events and find all events that overlap or are contained within a time window.
  • Manage genomic or biological sequence annotations where intervals represent features and you need to query overlaps.
  • Index spatial or temporal data where you need fast overlap detection between ranges without manual tree balancing.
  • Implement interval-based caching or memoization where you store results for ranges and retrieve them by overlap.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

intervaltree is a stable, well-maintained library with low install friction, permissive licensing, no known vulnerabilities, and a focused, proven API for a common data structure problem. Install it if you need to store and query overlapping or enveloped ranges; the self-balancing design and rich query interface make it significantly easier than building your own tree.

Install

intervaltree on PyPI

Before you install

Low install friction with a single pure-Python runtime dependency (sortedcontainers). The package is in production-stable status and has been actively maintained, with the latest release in 2025 and repository last commit in 2025. Supports Python 2.7 and 3.5 through 3.14.

License in practice

Licensed under Apache-2.0 (permissive), allowing commercial use, modification, and distribution with minimal restrictions—suitable for most projects.

Quickstart

pip install intervaltree

from intervaltree import Interval, IntervalTree

t = IntervalTree()
t[1:5] = "data"
result = sorted(t.overlap(2, 4))
print(result)

Verify before relying

  • Whether the package's AVL balancing guarantees specific query performance characteristics (e.g., O(log n) lookups) under typical usage patterns.
  • Real-world performance comparison with alternative interval tree implementations for large datasets.

Package facts

LicenseApache-2.0 permissive
Python supportSupports the current Python release !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7.18
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
sortedcontainers
MaintenanceAging 233 days since the last release
Last repo commit
First released
Downloads6,271,448 / month, #1,942 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPyTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: Bio-InformaticsTopic :: Scientific/Engineering :: Information AnalysisTopic :: Software Development :: LibrariesTopic :: Text Processing :: GeneralTopic :: Text Processing :: LinguisticTopic :: Text Processing :: Markup

Evidence: intervaltree-3.2.1-py2.py3-none-any.whl

Tags

Capabilities
interval tree data structurerange overlap queriestime interval storagepoint and range queriesself-balancing interval treetext tagging intervalsoverlapping ranges
Topics
data-structureinterval-queriesrange-search
PyPI keywords
data-structureinterval-treeintervalstree

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “interval tree data structure”

  • intervaltreeA self-balancing interval tree data structure that stores and queries…
  • nclsNCLS provides a fast interval overlap query data structure…
  • portionportion provides data structures and operations for working with…

Give your agent the search over MCP, or paste the wish link into any chat.

More Libraries packages

urllib3 Worth it
PyPI · Libraries · released May 2026

urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.

MITpure Python · 3.10+
1.8Bdownloads / mo
requests Worth it
PyPI · Libraries · released May 2026

Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.

Apache-2.0pure Python · 3.10+
1.8Bdownloads / mo
pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
python-dateutil Worth it
PyPI · Libraries · released Mar 2024

Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.

Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.

Apache-2.0pure Python
1.2Bdownloads / mo
six With conditions
PyPI · Libraries · released Dec 2024

Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.

MITpure Python
1.2Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo

See also ncls · red-black-tree-mod · portion · intervals · apted · igwn-segments · pyranges · adjustText · MAPIE · rcslice