A fast and efficient percentile calculator written in Rust.
Project description
Motivation
When you’re processing load test timings (or any latency distribution), you typically want buckets like p50/p95/p99 quickly. percently provides a small, fast Rust implementation exposed to Python.
Features
- Fast: Rust core
- Simple API: one call to compute a percentile
- Python-friendly: works with regular lists/iterables of floats
Installation
Using uv:
uv add percently
Using pip:
pip install percently
🧮 Usage
import percently
data = [10.5, 22.0, 18.7, 19.2, 30.1, 25.3]
# Calculate the 95th percentile (f64)
p95 = percently.percentile(data, 95)
print(f"95th percentile: {p95:.2f}")
Streaming (iterative) percentile estimates
If you have a generator/iterable and want running percentile estimates without loading all values into memory, use stream.
import percently
def timings():
for i in range(1, 1_000_001):
yield float(i % 10_000) / 10_000.0
# Yield an updated p95 estimate every 1000 samples (approximate, bounded memory)
for est in percently.stream(timings(), 95, every=1000):
last = est
print("final approx p95:", last)
Notes:
stream(..., 0, ...)yields the running min (exact)stream(..., 100, ...)yields the running max (exact)- All values must be finite floats (no NaN/inf)
Development
Build/install locally (editable) with maturin:
uv sync
uv run maturin develop
Releasing
This repo is configured for signed release commits/tags and tag-based publishing:
- Create a signed tag (e.g.
0.1.4) - GitHub Actions (tag-triggered) builds wheels/sdist and publishes to PyPI
Recommended (cargo-style) tool: cargo-release
cargo install cargo-release
# Patch release: bumps Cargo.toml version, commits (signed), creates signed tag, pushes
cargo release patch --execute
License
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file percently-0.1.4.tar.gz.
File metadata
- Download URL: percently-0.1.4.tar.gz
- Upload date:
- Size: 68.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1233c61c94e002ea659ed8ac34f0b397b24ba69703e34454d6cd0bb7c17c82ad
|
|
| MD5 |
c5046be2c6b6dcade0acc080d8c96c0a
|
|
| BLAKE2b-256 |
ff4ad9b41795758ea340e2ea13af2a2097e4d36abd1fa8ece2557b8dbc7bdb9a
|
File details
Details for the file percently-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: percently-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 201.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
993b07d643cf305c58672567e16470aa6e01eb0fb9078844a967ba19158e93f4
|
|
| MD5 |
c89f3a7e451ce5d0805b3b26bd984f3b
|
|
| BLAKE2b-256 |
cd11a7cb2f17da40c522936ecce49716a8baaccb2546aefb481e7f755549c49b
|