rangeslib
rangeslib is a typed Python library for eager, C++-inspired range pipelines.
The public API is intentionally small:
from rangeslib import ranges, views
The mental model is:
ranges creates values
views transforms values
views.to converts the final result
Quick Start
from rangeslib import ranges, views
result = (
ranges.iota(1, 11)
| views.filter(lambda value: value % 2 == 0)
| views.transform(lambda value: value * 10)
| views.take(3)
| views.to(list)
)
assert result == [20, 40, 60]
Range values are eager and reusable. Most adaptors return another Range; the
terminal views.to(...) adaptor returns whatever collection or factory you ask
for.
Existing Iterables
Ordinary Python iterables can start pipelines too:
from rangeslib import views
text = "abcdef" | views.take(3) | views.to(str)
assert text == "abc"
chars = "abc" | views.all()
assert list(chars) == ["a", "b", "c"]
views.all() is the eager Python counterpart to C++ views::all: it adapts an
existing iterable into a reusable Range.
Reusable Pipelines
Adaptors can be composed before data is supplied:
from rangeslib import views
first_three_even = views.filter(lambda value: value % 2 == 0) | views.take(3)
assert list([1, 2, 3, 4, 5, 6] | first_three_even) == [2, 4, 6]
assert list([10, 11, 12, 14] | first_three_even) == [10, 12, 14]
Sources And Views
The ranges facade creates source ranges:
from rangeslib import ranges
ranges.empty()
ranges.single("value")
ranges.iota(1, 5)
ranges.indices(3)
ranges.repeat("x", 3)
The views facade contains transformations such as:
all, reverse, filter, transform, take, drop, counted,
elements, keys, values, enumerate, concat, zip, cartesian_product,
adjacent, pairwise, chunk, slide, stride, join, split, to
See docs/usage.md for the full API catalog.
C++ Ranges Correspondence
rangeslib borrows naming and broad behavior from C++20/23/26 ranges, but it
is not a lazy C++ view implementation. The most important differences are:
- Python iterables replace C++ iterator/sentinel pairs.
Rangestores eager values instead of reference-like lazy views.- Tuple results are ordinary Python tuples, not tuples of references.
- Python type checking is useful but cannot express every C++ tuple-like rule.
See docs/cpp-comparison.md for details.
Installation
Python 3.12 or newer is required.
python -m pip install .
For development:
python -m pip install -e ".[dev]"
rangeslib has no runtime dependencies.
The 1.x series preserves the documented Range, ranges, and views public
API. Private modules and implementation classes are not part of the
compatibility contract; breaking public changes require a new major version.
Development
Useful commands live in scripts/:
./scripts/run_tests.sh # tests only
./scripts/typecheck.sh # mypy + Pyright
./scripts/check.sh # Ruff, typing, tests, coverage
./scripts/check_all.sh # check.sh + strict Sphinx docs
./scripts/check_package.sh # sdist/wheel build and install smoke test
./scripts/run_playground.sh # manual playground
Before a release commit, run:
./scripts/check_all.sh
./scripts/check_package.sh
Documentation
Build the Sphinx site with:
./scripts/generate_docs.sh
Generated HTML is written to docs/_build/html/ and published to GitHub Pages
after CI succeeds on main.
Releases
Changing [project].version in pyproject.toml on main automatically runs
the complete quality and package checks, then creates the matching Git tag and
GitHub Release and publishes the distribution to PyPI through Trusted
Publishing after the PyPI project is configured.
For future work, prefer opening or collecting issues before adding more adaptors immediately. See docs/roadmap.md.
See docs/publishing.md for the PyPI setup checklist.
Metadata
Release files for rangeslib 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rangeslib-1.0.0.tar.gz | 35.1 kB | With provenance | Details for rangeslib-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rangeslib-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for rangeslib-1.0.0-py3-none-any.whl |
Total release size: 47.8 kB
Release files / rangeslib-1.0.0.tar.gz
| Download URL | rangeslib-1.0.0.tar.gz |
|---|---|
| Size | 35.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
433c8fbc3a38e4709f2f8f2f3fdd2adeaa6f69bbaee95208f474983a5d358664
|
|
BLAKE2b-256 checksum How to use checksums |
400dd938311b9bd509845e7e1ad8b694fc87c98f4e3e793f27aa4fed390fa1bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logRelease files / rangeslib-1.0.0-py3-none-any.whl
| Download URL | rangeslib-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4570f74edfb8e5ecf3dd076fa6b194d05d70a48a9489c7c628cb80b98e80139
|
|
BLAKE2b-256 checksum How to use checksums |
3868a90d174bd9d14fc570394340a356b3161d61c94087ce36c97dc30a1aa158
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logSecurity for rangeslib 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for rangeslib-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.