datasketches
The Apache DataSketches Library for Python
What it is and what it does
DataSketches is a Python binding to the Apache DataSketches library, a collection of streaming algorithms designed to answer expensive big-data queries approximately but with mathematically proven error bounds. Instead of computing exact results (which may require prohibitive compute time and resources), sketches trade precision for speed—often delivering results orders of magnitude faster. The library includes algorithms for cardinality estimation (HLL, CPC), quantile approximation (KLL, REQ, Quantiles), frequent-item detection, set operations (Theta, Tuple), sampling (VarOpt, EBPPS), and specialized tools like count-min sketches and kernel density estimation.
The package wraps C++ implementations via nanobind, providing a Python API that closely mirrors the C++ interface. It depends on numpy and is distributed as precompiled wheels for modern Python versions and common platforms. The library is portable across languages when endianness matches, making it suitable for systems that need to serialize sketches across different environments. Use it when exact answers are infeasible but approximate results with error guarantees are acceptable—typical scenarios include real-time analytics, interactive queries on massive datasets, and distributed systems where communication overhead dominates.
Use it for:
- Estimate cardinality (distinct count) in a data stream without storing all unique values.
- Compute approximate quantiles and percentiles from unbounded data streams with controlled error.
- Identify frequent items or heavy hitters in a stream with false-positive/negative guarantees.
- Perform approximate set operations (union, intersection) on large datasets with memory efficiency.
- Implement real-time analytics dashboards where exact results are unnecessary but speed is critical.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides streaming algorithms (sketches) for approximate answers to big-data queries like cardinality estimation, quantiles, and frequent items with proven error bounds and orders-of-magnitude speed gains.
Yes, if you need approximate answers to expensive big-data queries with proven error bounds and can tolerate a 531-day release gap. The library is stable, well-maintained under Apache governance, has no known vulnerabilities, and offers a mature API. Install friction is moderate due to C++ compilation, but prebuilt wheels reduce friction for standard platforms. Not suitable if you require exact results or need active feature development.
Install
datasketches on PyPI
pip
pip install datasketchesuv
uv add datasketchespoetry
poetry add datasketchesInstalling datasketches
Before you install
Medium install friction due to compiled C++ bindings; prebuilt wheels available across macOS, Linux, and Windows. Last release 531 days ago; maintenance status is aging.
License in practice
Apache 2.0 permissive license; precompiled binaries include nanobind (BSD license). No restrictions on commercial use or modification.
Quickstart
pip install datasketches
import datasketches
sketch = datasketches.kll_floats_sketch()
for value in data:
sketch.update(value)
print(sketch.get_quantile(0.5))
Requires numpy as a runtime dependency; C++ bindings require a compatible platform (wheels provided for common architectures).
Verify before relying
- Whether the 531-day gap since last release indicates active maintenance or dormancy under Apache governance.
- Exact Python version support (requires_python not specified in metadata).
- Performance characteristics and memory overhead compared to alternatives for specific sketch types.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | aging — 531 days since the last release |
| First released | |
| Downloads | 1,205,968/month — #4,222 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: datasketches-5.2.0-cp310-cp310-macosx_10_14_x86_64.whl; datasketches-5.2.0-cp310-cp310-macosx_11_0_arm64.whl; datasketches-5.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; datasketches-5.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; datasketches-5.2.0-cp310-cp310-musllinux_1_2_aarch64.whl; datasketches-5.2.0-cp310-cp310-musllinux_1_2_x86_64.whl; datasketches-5.2.0-cp310-cp310-win_amd64.whl; datasketches-5.2.0-cp311-cp311-macosx_10_14_x86_64.whl; datasketches-5.2.0-cp311-cp311-macosx_11_0_arm64.whl; datasketches-5.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; datasketches-5.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; datasketches-5.2.0-cp311-cp311-musllinux_1_2_aarch64.whl; datasketches-5.2.0-cp311-cp311-musllinux_1_2_x86_64.whl; datasketches-5.2.0-cp311-cp311-win_amd64.whl; datasketches-5.2.0-cp312-cp312-macosx_10_14_x86_64.whl; datasketches-5.2.0-cp312-cp312-macosx_11_0_arm64.whl; datasketches-5.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; datasketches-5.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; datasketches-5.2.0-cp312-cp312-musllinux_1_2_aarch64.whl; datasketches-5.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
Tags
More Information Analysis packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyarrowpyarrow provides Python bindings to Apache…
permissive · top 100 on PyPI
networkxNetworkX provides data structures and…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
snowflake-snowpark-pythonSnowpark Python provides APIs to query and…
permissive · top 1,000 on PyPI
datasketchProvides probabilistic data structures…
permissive · top 5,000 on PyPI
ddsketchDDSketch computes quantiles (percentiles) of…
permissive · top 5,000 on PyPI
madokaMadoka implements a Count-Min sketch data…
permissive · top 15,000 on PyPI
whylogs-sketchingProvides Python bindings to Apache…
permissive · top 15,000 on PyPI
crickCrick provides approximate and streaming…
permissive · top 15,000 on PyPI
HLLEstimates the cardinality (unique count) of…
permissive · top 15,000 on PyPI
fig2sketchConverts Figma .fig design files into Sketch…
unclear · top 15,000 on PyPI
tdigestImplements Ted Dunning's t-digest data…
permissive · top 15,000 on PyPI
fastdigestfastdigest provides a Rust-backed t-digest…
permissive · top 15,000 on PyPI
libcuvs-cu12GPU-accelerated vector search and clustering…
permissive · top 15,000 on PyPI