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.
Metadata
Release files for wavelet-matrix 4.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 |
|---|---|---|---|---|
| wavelet_matrix-4.0.0.tar.gz | 70.9 kB | With provenance | Details for wavelet_matrix-4.0.0.tar.gz |
Built distributions (wheels)
Total release size: 14.2 MB
Release files / wavelet_matrix-4.0.0.tar.gz
| Download URL | wavelet_matrix-4.0.0.tar.gz |
|---|---|
| Size | 70.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f64e6d684928016932a106edbb51a63ea56c7dff8ea7ed4ad50450131ef4123b
|
|
BLAKE2b-256 checksum How to use checksums |
22bbe01fce351112b17f7f4ba8339f03fc11f943f145a2313db2d66a43ed9b03
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-win_amd64.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 637.2 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1ef0e529b4a2c75723106c6dcc109655167cbafcb3273e9f16ca3a0b9b836510
|
|
BLAKE2b-256 checksum How to use checksums |
a7782b79df35e77556eca0a764aafcea48003354503d9d48bf592ad831321ed3
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-win32.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-win32.whl |
|---|---|
| Size | 618.1 kB |
| Tags | CPython 3.11 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
8fbc1fdefb150fd367a78dc489dc28c7c94006e66b8f850d8f0a1d75dbd1df8a
|
|
BLAKE2b-256 checksum How to use checksums |
9393811ef469011ccbab441da90744a1a25b1def770eec6ddb5247d30e9f108a
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_x86_64.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
64fdbfd33ec1174ffbab813407375fca73683003b063edb3f7f1bc86611dd571
|
|
BLAKE2b-256 checksum How to use checksums |
4dbca5fb3ac8b72bfc386015886de38995f724d8f7070ae4ad7e623d4f12c500
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_i686.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_i686.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
f0e662aad7cb3aa25452db1f24f9859363a3aeb9ab91c208445dc7462aadfa00
|
|
BLAKE2b-256 checksum How to use checksums |
052cc11199bcd73e3d08c21d6db4eda4cdbfa4e8660cb5b805094373a7dcc0e5
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_armv7l.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.11 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
0c59b2f3ce2fe160251919d4910269ea9d4174bb720a73d6d74c921e453290c7
|
|
BLAKE2b-256 checksum How to use checksums |
bdccd706694dd9e1563760fb29dbc5bc4692824ca777a32121418749b277ad7d
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_aarch64.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8c4087283e17a6bcc5c19c1aec19f5a4ff9885d1650b2260f4bbea9632ef5720
|
|
BLAKE2b-256 checksum How to use checksums |
22d645adcda5c43ce1a9a8938b75f76446ea88bb54cea825fe9736eedfee9409
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 928.4 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f88c54e939df8418ad310c44419df80209341f7e91b8b285709b2ad88442517c
|
|
BLAKE2b-256 checksum How to use checksums |
ad11608652f4f58b23846adc3139a184f94e3fb6fc8995869744d0624b84b858
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ IBM System/390x abi3 |
|
SHA-256 checksum How to use checksums |
9906c7c5e35c88bb83563b79b5ae3abb33f5a65852aba355f002e19ad257a205
|
|
BLAKE2b-256 checksum How to use checksums |
16f091311c0c970b7ffeadc26848b6473c0f1adf3c57462c1be37792800a8077
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
027f1f1686f64827f5969d2291437d0fd4b72af0a2d33e672ace660687327016
|
|
BLAKE2b-256 checksum How to use checksums |
51fa8fc22605de9e5e7534cb4d5eaa4da6347959773c656c2e3d777308dc96ba
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
9a85095e211cd62d0adfbeee7d10d1a95f34de053b54d86b1a85c19316fa361f
|
|
BLAKE2b-256 checksum How to use checksums |
446bde6634c130edee899c908bc5e0eca853f4e820068ca2e38d712e020a8a1e
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
bfa389c4cebaaee916b7b3d7fb981183440a11afb83867d99d5b3c623fc11a34
|
|
BLAKE2b-256 checksum How to use checksums |
b650cfe4abc50e03854c294f6f710014db48f007a87a2b415c3e5a094048b9a8
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 947.4 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
c77019ca1d0c6780441d6b103f2c2bbdcbadb53dc79ba7f2b1b5276ee1a7714c
|
|
BLAKE2b-256 checksum How to use checksums |
f84f1bbfb7c0ee59435e6c1f7e7edee8853cee4429f8ecdd1d91b3c724c12e49
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 836.7 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
291b2d485739d4b5ed83990f37b7915c747c158222fa7fd4cae56a1097cedf78
|
|
BLAKE2b-256 checksum How to use checksums |
2ccca09ad65318c37dc5e95de7fdaff1afc1c0be38e8db1a426496c18e7667fe
|
| 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 Oct 13, 2026.
Transparency logRelease files / wavelet_matrix-4.0.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | wavelet_matrix-4.0.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 874.4 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
975965a721fae2bd5d46e3f054c7c31e52ca7b65499344b9c76da79bd2549acb
|
|
BLAKE2b-256 checksum How to use checksums |
2947d6d8bd43b16067a6ff3fd71cd21b0e02470bea5d1cf4d82b4a7136d53b78
|
| 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 Oct 13, 2026.
Transparency logSecurity for wavelet-matrix 4.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
All 15 files in this release have been uploaded with provenance metadata.
Attestation for wavelet_matrix-4.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 Oct 13, 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.