Wavelet Matrix
High-performance Wavelet Matrix implementation powered by Rust,
supporting fast rank / select / range queries over indexed sequences
- PyPI: https://pypi.org/project/wavelet-matrix
- Document: https://math-hiyoko.github.io/wavelet-matrix
- Repository: https://github.com/math-hiyoko/wavelet-matrix
Features:
- Fast rank, select, quantile
- Rich range queries (freq / sum / top-k / min / max)
- Optional disk-backed storage for static WaveletMatrix (
on_disk=True) - Optional dynamic updates (insert / remove / update)
Installation
pip install wavelet-matrix
WaveletMatrix
WaveletMatrix indexes a static sequence of integers,
enabling fast queries where runtime depends on bit-width, not data size.
from wavelet_matrix import WaveletMatrix
data = [5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0]
wm = WaveletMatrix(data)
WaveletMatrix also supports disk-backed storage for large static sequences.
Set on_disk=True to keep its internal data on disk instead of holding it all in memory.
wm = WaveletMatrix(data, on_disk=True)
Frequency Queries
Count occurrences (rank)
wm.rank(value=5, end=9)
# 4
Find position (select)
wm.select(value=5, kth=4)
# 6
Order Statistics
k-th smallest value (quantile)
wm.quantile(start=2, end=12, kth=8)
# 5
Range Aggregation
Sum values (range_sum)
wm.range_sum(start=2, end=8)
# 24
Count values in [lower, upper) (range_freq)
wm.range_freq(start=1, end=9, lower=4, upper=6)
# 4
List values with counts (range_list)
wm.range_list(start=1, end=9, lower=4, upper=6)
# [{'value': 4, 'count': 1}, {'value': 5, 'count': 3}]
Top-K Queries
Most frequent values (topk)
wm.topk(start=1, end=10, k=2)
# [{'value': 5, 'count': 3}, {'value': 1, 'count': 2}]
Extreme values (range_maxk / range_mink)
wm.range_maxk(start=1, end=9, k=2)
# [{'value': 6, 'count': 1}, {'value': 5, 'count': 3}]
wm.range_mink(start=1, end=9, k=2)
# [{'value': 1, 'count': 2}, {'value': 2, 'count': 1}]
Boundary Queries
wm.prev_value(start=1, end=9, upper=7)
# 6
wm.next_value(start=1, end=9, lower=4)
# 4
DynamicWaveletMatrix
DynamicWaveletMatrix supports mutable sequences with insert/remove/update.
Trade-off:
- Higher overhead
- Values must fit within max_bit
from wavelet_matrix import DynamicWaveletMatrix
dwm = DynamicWaveletMatrix(data, max_bit=4)
Insert
dwm.insert(index=4, value=8)
Remove
dwm.remove(index=4)
Update
dwm.update(index=4, value=5)
# or dwm[4] = 5
Development
Running Tests
pip install -e ".[test]"
cargo test --all --release
pytest
Formating Code
pip install -e ".[dev]"
cargo fmt
ruff format
Generating Docs
pdoc wavelet_matrix \
--output-directory docs \
--no-search \
--docformat markdown \
--template-directory pdoc_templates
References
- Francisco Claude, Gonzalo Navarro, Alberto Ordóñez,
The wavelet matrix: An efficient wavelet tree for large alphabets,
Information Systems,
Volume 47,
2015,
Pages 15-32,
ISSN 0306-4379,
https://doi.org/10.1016/j.is.2014.06.002.
Release files for wavelet-matrix 2.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wavelet_matrix-2.2.7.tar.gz | 71.1 kB | Details |
Built distributions (wheels)
Total release size: 14.4 MB
Release files / wavelet_matrix-2.2.7.tar.gz
| Download URL | wavelet_matrix-2.2.7.tar.gz |
|---|---|
| Size | 71.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5dce80227ee982d43b2384a940d4d01df48c556d14b68ac784265765e0d5c6cc
|
|
BLAKE2b-256 checksum How to use checksums |
bdf8646f57e31257bd52c1e269a1b8b965de0ef63e6f03f870a74e3b6639c091
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-win_amd64.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 655.8 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e84a8350c39b50da732df4c64053f4a8a3e7045710ecde284189e815d7184129
|
|
BLAKE2b-256 checksum How to use checksums |
3de80ee8542cec8a8c850899844a1cfdc186923db25105dce427adf6cf8f88d5
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-win32.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-win32.whl |
|---|---|
| Size | 637.5 kB |
| Tags | CPython 3.9 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
0152e9867fd300057cb83031a980e164689ba90294119fdf09d29c91b2a25b0f
|
|
BLAKE2b-256 checksum How to use checksums |
4b3a77234d65dd5c0a987c5ea8c840b729e0ffb884956c7b9101e5b4fd6bbb5f
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
43cbff441efaa444cd133a9b501b9fc7fdcd66ffe89247ac7052864baa907617
|
|
BLAKE2b-256 checksum How to use checksums |
930a3ce72725c7dcc3d20efd35d3a2ce60b91a447187dc297a50ac9d81bce8ee
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_i686.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_i686.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
b69ca382c91f85f9240bb8f9da62d73faed630817f8b80a0eb3ac63a69e2e1e1
|
|
BLAKE2b-256 checksum How to use checksums |
f4df9ec849342e381c824020aa4392f10613bbef8219ef3848451c3cd6e0695d
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_armv7l.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
171c19ee77e7f1329cf2bb8cf6b0d54b499df98762dbbfcdcd08bcb78cb0c6f2
|
|
BLAKE2b-256 checksum How to use checksums |
e6ba3b2ca7b11cf300e270b41f6e519faa34dc6f01e47f941e354501287effe0
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
74b0ddf9407dd753743cd3960f3e470c6a6600de85dd8f2f5faaa118a9b44d87
|
|
BLAKE2b-256 checksum How to use checksums |
1ed6894b8ed551c49eb40bb75180257518108af67cc753cad4e511e3722d3dc6
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 942.7 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
666d90ce92a467825521c6d9ccb2cb7dd4dee15d98d591a0e8dd58c7ddf38c8c
|
|
BLAKE2b-256 checksum How to use checksums |
d25f820eb0346d1ea402fed75464c69d8befce3e5c5ff707758074c030543c5b
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ IBM System/390x abi3 |
|
SHA-256 checksum How to use checksums |
0533b070f7f2faa022e864222e69b4df1984ab0dd28fd1624fabfc033a15a8bf
|
|
BLAKE2b-256 checksum How to use checksums |
fa83ad577bef8cebdef34d2e9645b9a99e9f6f3a6b1cc04816845bf57b26ca7c
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
901375b1c1f831da6cde30e20e0874d10b9546d2c8c4804ea25234f87be33436
|
|
BLAKE2b-256 checksum How to use checksums |
a7dd430927d3912f74aa152a335211e49fb779517b0095a54ee2d482745634bc
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
2fb5e548a2634333b11740fdf50689dbfb163b826b5e841e6cda8b09b88de207
|
|
BLAKE2b-256 checksum How to use checksums |
a455de37165fec81a9d6157de86de54c59ba06e027c29e6e54e3d49df6cd4af2
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
8a9bb383b4b9773f5928af7dbc6626d64acb3cf2819ead672743e258c8ecfcff
|
|
BLAKE2b-256 checksum How to use checksums |
6153cefd4ad8c5b19edabe1ae93ca56a58ce3a75ab53d5dca55e163f8b840079
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 962.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8cb5217ed1de7b226d66291a5970f208ad5afec730d84f8d600218887123370d
|
|
BLAKE2b-256 checksum How to use checksums |
149e997aaf34a882e3a2e0176d32202028c93a49e5d289bf4ae331846abe15d9
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 852.1 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
097b71c67ff9b02c28d9d19a937f1167fcb926def8670622163374d4304b0060
|
|
BLAKE2b-256 checksum How to use checksums |
badb04182ac217cbb515df92aa71f79508af9c07b7a4dd9d84f3c9a8093b1efa
|
| 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 Aug 15, 2026.
Transparency logRelease files / wavelet_matrix-2.2.7-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | wavelet_matrix-2.2.7-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 888.7 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
2647b34899343765787387fa96c6fd00f688e412d2042ebef6c74b4d882623a0
|
|
BLAKE2b-256 checksum How to use checksums |
3698d2b17410edc934ecadc42d76919f24b452c3ac584a00eed53a3ed5126704
|
| 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 Aug 15, 2026.
Transparency log