Skip to main content

percently

Fast percentile calculator written in Rust — shipped as a Python package.

CI PyPI Python versions License Rust maturin

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.

Metadata

Release files for percently 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for percently 0.1.4
File Size Uploaded
percently-0.1.4.tar.gz 68.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for percently 0.1.4
File Interpreter ABI Platform
percently-0.1.4-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 270.0 kB

Release files / percently-0.1.4.tar.gz

Download URL percently-0.1.4.tar.gz
Size 68.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1233c61c94e002ea659ed8ac34f0b397b24ba69703e34454d6cd0bb7c17c82ad
BLAKE2b-256 checksum
How to use checksums
ff4ad9b41795758ea340e2ea13af2a2097e4d36abd1fa8ece2557b8dbc7bdb9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.4

Release files / percently-0.1.4-cp312-cp312-macosx_11_0_arm64.whl

Download URL percently-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Size 201.5 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
993b07d643cf305c58672567e16470aa6e01eb0fb9078844a967ba19158e93f4
BLAKE2b-256 checksum
How to use checksums
cd11a7cb2f17da40c522936ecce49716a8baaccb2546aefb481e7f755549c49b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.4

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page