Registry / data / fastdigest

fastdigest

JSON →
library0.12.0pypypi✓ verified 86d ago

Fastdigest is a Python library that provides a lightning-fast implementation of the t-digest data structure, built on Rust. It offers a lightweight suite of online statistics for streaming and distributed data, enabling accurate estimation of quantiles, CDF, trimmed mean, and more. The library is currently at version 0.12.0 and maintains an active release cadence.

pip install fastdigest
INSTALL
IMPORT
SIG · FASTDIGEST
F
fastdigest
datapythonv0.12.0
Install
1.8s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.8s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TDigest
from fastdigest import TDigest

Initialize a TDigest, update it with streaming or batch data, and query for quantiles, median, and other statistics.

from fastdigest import TDigest import random # Create a new TDigest instance digest = TDigest() # Add values incrementally for _ in range(10000): digest.update(random.random() * 100) # Or create from a sequence of values (with optional weights) data = [1.42, 2.71, 3.14, 5.0, 8.0, 13.0] digest_from_values = TDigest.from_values(data) # Add a batch of values digest_from_values.batch_update([1.0, 2.0, 3.0, 4.0]) # Get quantiles median = digest.quantile(0.5) percentile_90 = digest.quantile(0.9) print(f"Median: {median:.2f}") print(f"90th Percentile: {percentile_90:.2f}") # Get the number of centroids print(f"Number of centroids: {len(digest)}") # Check if empty (as method) print(f"Is digest empty? {digest.is_empty()}")
Debug
Known issues
breakingThe `mass` and `is_empty` attributes were converted from properties to methods. Attempting to access them as properties will now raise an `AttributeError`.
fix
Change calls from `digest.mass` to `digest.mass()` and `digest.is_empty` to `digest.is_empty()`.
affects: >=0.12.0
breakingThe `max_centroids` setter and constructor arguments changed their internal type handling and validation. Attempting to set negative `max_centroids` will now raise a `ValueError` (previously could cause an `OverflowError` or unexpected behavior).
fix
Ensure `max_centroids` is always a non-negative integer when initializing `TDigest` or modifying its property.
affects: >=0.9.0
gotchaThe `std()` method's estimation was significantly improved in v0.12.0. It now estimates population variance via centroid second moments, making it more accurate and faster than the previous MAD-based estimation (from v0.11.0), which was only strictly valid for approximately normal distributions. Results for non-normal distributions will differ.
fix
Be aware that `std()` results may be different and more accurate compared to versions prior to 0.12.0, especially for non-normal data distributions.
affects: >=0.12.0
gotchaCalling `merge_all` with an iterable containing non-`TDigest` objects will now explicitly raise a `TypeError` instead of potentially panicking or leading to unexpected behavior.
fix
Always ensure that all elements within the iterable passed to `merge_all` are valid `TDigest` instances.
affects: >=0.8.1
Errors
Common errors & fixes
AttributeError: 'TDigest' object has no attribute 'mass'
In versions 0.12.0 and later, `mass` was changed from a property to a method.
fix
Call `mass` as a method: `digest.mass()`
AttributeError: 'TDigest' object has no attribute 'is_empty'
In versions 0.12.0 and later, `is_empty` was changed from a property to a method.
fix
Call `is_empty` as a method: `digest.is_empty()`
ValueError: max_centroids must be a non-negative integer
Attempting to initialize `TDigest` or set `max_centroids` with a negative value or non-integer type.
fix
Ensure that `max_centroids` is always a non-negative integer value, e.g., `TDigest(max_centroids=50)`.
TypeError: object of type 'int' has no len() (or similar when merging non-TDigest objects)
The `merge_all` method received an iterable containing objects that are not `TDigest` instances.
fix
Verify that all elements in the list or iterable passed to `TDigest.merge_all()` are indeed `TDigest` objects.
MemoryError: failed to allocate TDigest (possibly during merge operation)
The `TDigest` attempted to allocate memory for a large number of centroids, exceeding available system memory. This can happen with very large merges or when `max_centroids` is set too high for the data volume.
fix
Consider reducing the `max_centroids` parameter to limit memory usage, process data in smaller batches, or ensure sufficient memory is available for large operations.
Upgrade
Version history
0.12.0latest on PyPI · released Mar 15, 2026
Audit
Dependencies
numpyoptionalOptional dependency for efficient weighted updates and array-based initialization methods like `TDigest.from_values` with `w` argument.
Agent activity
6 hits · last 30 days
node
6
Resources
fastdigest — pip install fastdigest · libregistry