Metadata-Version: 2.4
Name: sbits
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Summary: Succinct data structures: BitVector with O(1) rank/select, Elias-Fano, WaveletTree.
Keywords: succinct,bitvector,rank-select,elias-fano,data-structures
Author-email: Arc <attobop@gmail.com>
License: MIT OR Apache-2.0
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://docs.rs/sbits
Project-URL: Homepage, https://github.com/arclabs561/sbits
Project-URL: Repository, https://github.com/arclabs561/sbits

# sbits

Python bindings for the [sbits](https://crates.io/crates/sbits) Rust crate.

Provides succinct data structures with near-optimal space and efficient queries:

- **BitVector** -- rank and select in O(1) time with o(n) auxiliary space.
- **EliasFano** -- compressed sorted integer sequences with O(1) random access.
- **WaveletTree** -- rank, select, and access over arbitrary alphabets in O(log sigma) time.

## Installation

```
pip install sbits
```

## Usage

```python
from sbits import BitVector, EliasFano, WaveletTree

# Bit vector with rank/select
bv = BitVector([True, False, True, True, False, True])
bv.rank(4)    # 3 (number of set bits in [0, 4))
bv.select(2)  # 3 (position of 3rd set bit, 0-indexed)

# Elias-Fano for sorted integers
ef = EliasFano([10, 20, 30, 100, 1000])
ef[0]         # 10
30 in ef      # True

# Wavelet tree
wt = WaveletTree([3, 1, 2, 0, 3, 0, 1, 2], sigma=4)
wt.access(0)     # 3
wt.rank(3, 8)    # 2
wt.select(3, 0)  # 0
```

