paged-collections
Paged sparse sets, maps, a priority queue and stable-address containers for
Rust (no_std + alloc), with Python bindings built on PyO3 and NumPy.
The keyed collections use a paged index. The first write to a page
allocates it. The default Flat directory stores a pointer slot for every
page number up to the highest one used. Radix and Tree can skip gaps
between page numbers, which saves directory space when keys are far apart.
With paged storage, existing elements keep their addresses as the container grows.
Install
cargo add paged-collections # features: std (default), serde, rayon, concurrent
pip install paged-collections # Python 3.10+, NumPy 1.24+
Wheels cover CPython 3.10+ (abi3) and free-threaded 3.14t and 3.15t+.
See Installation.
Example
Rust:
use paged_collections::direct_map::PagedDirectMap;
use paged_collections::hive::Hive;
use paged_collections::id_alloc::Id;
let mut hive: Hive<&str> = Hive::new();
let a = hive.insert("a");
let b = hive.insert("b");
let mut score: PagedDirectMap<Id, u32> = PagedDirectMap::new();
score.insert(a, 10);
score.insert(b, 20);
// Removing frees the slot; its next occupant gets a new generation, so the
// stale id misses in the hive, and the new id misses the side-table entry
// left by the old one. Side tables are not cleaned up automatically.
hive.remove(a);
let c = hive.insert("c");
assert_eq!(c.index(), a.index());
assert_eq!(hive.get(a), None);
assert_eq!(score.get(c), None);
assert_eq!(score.remove(a), Some(10));
// A direct map iterates in slot order and answers range queries.
let in_range: Vec<u32> = score.range(a..=b).map(|(_, &s)| s).collect();
assert_eq!(in_range, [20]);
Python:
import numpy as np
from paged_collections import sparse_map
m = sparse_map("float64")
m.set_many(np.arange(0, 3_000_000, 1000), 1.0) # batch insert
m[7] = 2.5
m.get_many([7, 1000]) # array([2.5, 1. ])
values = m.values_view() # zero-copy, writeable
values *= 2 # updates the map in place
del values # resizing raises BufferError while a view is alive
Containers
| Rust | Python | Paging | Purpose |
|---|---|---|---|
PagedBitSet<K> |
BitSet |
index | One bit per slot in each allocated page, with key order and range operations |
PagedSparseSet<K> |
SparseSet |
index | Integer set: O(1) insert, remove, contains, clear; dense iteration |
PagedSparseMap<K, V> |
SparseMap, SparseMapF64, ... |
index | Sparse set with a dense value array |
PagedDirectMap<K, V> |
DirectMap, DirectMapF64, ... |
index | Values in place; key order and range queries |
PagedPriorityQueue<K, P> |
PriorityQueue, PriorityQueueF64 |
index | Indexed heap: priority changes and removal by key |
PagedVec<T> |
PagedList, PagedListF64, ... |
storage | Growable vector with stable addresses |
PagedDeque<T> |
PagedDeque |
storage | Double-ended queue with stable addresses |
Hive<T> |
Hive |
storage | Unordered slots with generational ids |
IdAllocator |
IdAllocator, IdMap |
none | Generational ids for use as keys |
The rayon feature enables parallel iteration through rayon::prelude.
Concurrent containers
The concurrent feature (no_std compatible) adds thread-safe containers.
They grow through shared references (&self), and pages stay at fixed
addresses until exclusive access (&mut self), so lookups need no epochs or
hazard pointers. The Python classes can be shared between threads, including
on free-threaded builds; their batch methods (*_many) release the GIL.
| Rust | Python | Shared operations (&self) |
Lookups |
|---|---|---|---|
ConcurrentSparseSet<K> |
ConcurrentSparseSet |
insert | &K |
ConcurrentSparseMap<K, V> |
ConcurrentSparseMapF64, ... |
insert | &V |
ConcurrentDirectMap<K, V> |
ConcurrentDirectMapF64, ... |
insert, replace, remove, entry (per-page RwLock) |
closure, clone or entry guard |
AtomicDirectMap (usize -> u64), AtomicIdMap (Id -> u32) |
— | lock-free insert, update, remove | copied value |
ConcurrentQueue<T> |
ConcurrentQueue |
push, pop (FIFO) | owned value from pop |
ConcurrentPriorityQueue<K, P> |
ConcurrentPriorityQueue, ConcurrentPriorityQueueF64 |
push, change priority, remove, relaxed pop, exact pop_exact |
cloned priority |
ConcurrentPagedVec<T> |
— | push | &T |
ConcurrentHive<T> |
— | insert, remove, take | Ref guard |
ConcurrentAppendHive<T> |
— | insert | &T |
ConcurrentIdAllocator |
— | alloc, free |
Removal from the sparse set, sparse map and append-only containers, as well
as clear, shrink_to_fit and conversion to the sequential types, needs
&mut self; in Python, such a call raises RuntimeError if it conflicts
with another thread. See
Concurrent containers.
Documentation
- Paging model:
page sizes,
Flat/Radix/Treedirectories, memory behaviour. - Choosing a container: when each container fits, and when a standard one is better.
- Benchmarks: reference measurements and the commands to reproduce them.
- API: docs.rs (Rust),
_core.pyi(Python).
Layout
paged-collections/
├── crates/
│ ├── paged-collections/ # Rust library (no_std + alloc)
│ ├── paged-collections-python/ # PyO3 bindings for the _core extension
│ └── bench/ # Rust benchmarks outside the default build
├── python/
│ └── paged_collections/ # Python sources and type stubs
├── tests/ # Python tests
├── benchmarks/
│ └── python/ # Python benchmarks
└── docs/
└── site/ # mdBook documentation
Development commands are in CONTRIBUTING.md.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Metadata
Release files for paged-collections 0.2.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 |
|---|---|---|---|---|
| paged_collections-0.2.0.tar.gz | 533.6 kB | Without provenance | Details for paged_collections-0.2.0.tar.gz |
Built distributions (wheels)
Total release size: 29.3 MB
Release files / paged_collections-0.2.0.tar.gz
| Download URL | paged_collections-0.2.0.tar.gz |
|---|---|
| Size | 533.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adbf0ef0d884aa1dfabb67940c3bcc3dcbd805635a330d1913defd6419878dce
|
|
BLAKE2b-256 checksum How to use checksums |
9a0041a9a87c947decefa9fe9cf368f3abd0a43d3917f53c3aa31a90ce83611a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp315-abi3.abi3t-win_amd64.whl
| Download URL | paged_collections-0.2.0-cp315-abi3.abi3t-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.15 Windows x86-64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
3e9065924583508c8db090500788a6055ddc1a649bf8ddbfc37cbd5bfc227ea1
|
|
BLAKE2b-256 checksum How to use checksums |
5a4ff1d033ac0610cbd0b17858b29481529e9905a2e7a3385a4fb4b8e026820d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
| Download URL | paged_collections-0.2.0-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ x86-64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
60b0f20f82bef0a6109e0162bfb521ef72a1983710b4b0d9127b796253b2b071
|
|
BLAKE2b-256 checksum How to use checksums |
6fc351648d73a5078e56eb5d0862e55e4cfa99011763502ed3bcfde78268cb2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
| Download URL | paged_collections-0.2.0-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ ARM64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
3b6f9a797b77a92045b97a5ccd8d89c8143483e9915e283c4582b042d8c602b8
|
|
BLAKE2b-256 checksum How to use checksums |
84ec547a69ed9ff9f94b8e4ef4dd2f6494a81d6b03cd3b332d2b29701de08c96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp315-abi3.abi3t-macosx_11_0_arm64.whl
| Download URL | paged_collections-0.2.0-cp315-abi3.abi3t-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.15 abi3 abi3t macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e996955c785038752581225af38f28c3d16af99609efaa2052d280f421d11a21
|
|
BLAKE2b-256 checksum How to use checksums |
358fdf145414eb438bf4269de8737215bd30974dde5caba44b0eb3b59e12d963
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp315-abi3.abi3t-macosx_10_12_x86_64.whl
| Download URL | paged_collections-0.2.0-cp315-abi3.abi3t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.15 abi3 abi3t macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c28fdbc9b996d6c8cd69619c6bf0b89ff2e5dcf0d2906bf126b84b1369e39f83
|
|
BLAKE2b-256 checksum How to use checksums |
d63df86bf0bcc1d8a7e34a181079d3ffd144e55f29b76bde69659c65b3af9559
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp314-cp314t-win_amd64.whl
| Download URL | paged_collections-0.2.0-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
39e806b143a64223a5f5e8e6a707b697b4deac37f14d906b5fdaee4266797e8a
|
|
BLAKE2b-256 checksum How to use checksums |
e2e10881f1187edcc4a79538edd82aa1eed3b4381f1118e441818a30897cea46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl
| Download URL | paged_collections-0.2.0-cp314-cp314t-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
c21b808dbe5a424bdba8a6853c4eda0faa08d7fbb70eb6238c0d168a400f7e48
|
|
BLAKE2b-256 checksum How to use checksums |
84ed2263b9d0b731026d6a06144815b999e6a08a613623c800d1131ff71861f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl
| Download URL | paged_collections-0.2.0-cp314-cp314t-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
33e0c869fcd18cddafd7073e264faad4e6d83da8f59858d2748bdb10493e59a0
|
|
BLAKE2b-256 checksum How to use checksums |
57e4f74e28ac1b6da1b80b38247e83482a35f6298dce18e40c303616c0e81c52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | paged_collections-0.2.0-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
94d6f3dadbc05326bd7ef292011200f7bc3a747b03ee0ba63741d8fc7fdb0c2d
|
|
BLAKE2b-256 checksum How to use checksums |
e29016516ebc3015e5e93de3fdc586a976348eb54b5cb63c482bd0db0e327cbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | paged_collections-0.2.0-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
ef5029fd0cfc955ac7e25d79d68f0d74b9b82be7b20b81cf84c0d6f6006baa85
|
|
BLAKE2b-256 checksum How to use checksums |
e3bf93569a4b13e29b244f43ce02a105fda6a89ca12d0337aa4af230997e0017
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp310-cp310-win_amd64.whl
| Download URL | paged_collections-0.2.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e08497829f374f21b61122bc0c06fec5170de6246a05d65aca881c6a97f83053
|
|
BLAKE2b-256 checksum How to use checksums |
05b4c0d526f3a25475aeadee240fba965ad24b06fd2653df2f821d4ff4b4335e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | paged_collections-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
addac89525d337c2114def76756b1780ca96fa9344a34b21850325775b130dff
|
|
BLAKE2b-256 checksum How to use checksums |
06a4fb6a6f08551fd74bb71821305dd8a1d2e1f4d01d7f2bb6741bf4c6bb5c36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp310-cp310-manylinux_2_28_aarch64.whl
| Download URL | paged_collections-0.2.0-cp310-cp310-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
d4a49c9acf6e047b5cf7cd4839f277c08a8ffccb4d3f8c4e54587cfb5f2f8b44
|
|
BLAKE2b-256 checksum How to use checksums |
3a3ad03354b8a7e2b4e8d484cff0614173d50136d0c35c3c3ed7d28a65f6a068
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | paged_collections-0.2.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
273ea81e0a2c5cb7d937027d4e8b5f86a284dff75ccd48697044b8f880f81099
|
|
BLAKE2b-256 checksum How to use checksums |
a0a65cbeb7ac320c736a2774dd4d893f8ed5d41f214af460ee56400a5e529bda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / paged_collections-0.2.0-cp310-cp310-macosx_10_12_x86_64.whl
| Download URL | paged_collections-0.2.0-cp310-cp310-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b639302f94477698ac206b992e830d0bf24c98881906260006510f09dd23a89e
|
|
BLAKE2b-256 checksum How to use checksums |
02772a5580e8e36ccbef13ac861b35a52631826315314c68f311f15b39b626e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for paged-collections 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.