datasketch
Probabilistic data structures for processing and searching very large datasets
What it is and what it does
datasketch implements a collection of probabilistic sketching algorithms—MinHash, Weighted MinHash, HyperLogLog, and HyperLogLog++—that compress large sets into compact signatures for fast approximate computation. It's built on numpy and scipy and designed to handle datasets too large for exact computation by trading small accuracy loss for dramatic speed and memory gains. The package also provides indexes (MinHash LSH, LSH Forest, LSH Ensemble, HNSW) that enable sub-linear query time for similarity search and top-k retrieval.
Version 2.0.0 changes the default MinHash permutation scheme to affine32, which reduces memory by half and speeds updates roughly 4x while fixing a similarity over-estimation bias on large sets. Existing persisted sketches must be rebuilt or interoperated via a legacy scheme flag. The package supports Python 3.9+ and optional Redis or Cassandra backends for distributed storage of LSH indexes.
Use it for:
- Estimate Jaccard similarity between large text documents or sets without computing exact overlap.
- Count approximate cardinality of massive streams or datasets using HyperLogLog sketches.
- Build fast similarity search indexes over millions of items using MinHash LSH for threshold queries.
- Retrieve top-k most similar items from a large corpus using LSH Forest or HNSW indexes.
- Detect near-duplicate content or deduplication in data mining pipelines with minimal memory.
- Estimate containment relationships between sets at scale using LSH Ensemble.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides probabilistic data structures (MinHash, HyperLogLog, and related indexes) for fast similarity estimation and cardinality counting on large datasets with minimal memory overhead.
Yes. datasketch is production-stable (Development Status 5), actively maintained, has no known vulnerabilities, and solves a real problem—approximate similarity and cardinality at scale with low install friction. The MIT license is unrestricted. Version 2.0.0's breaking changes to MinHash serialization are a one-time migration cost but necessary for correctness and performance; the legacy scheme option eases interop. Install if you need fast approximate set operations on large data.
Install
datasketch on PyPI
pip
pip install datasketchuv
uv add datasketchpoetry
poetry add datasketchInstalling datasketch
Before you install
Low friction: pure Python wheel with only numpy and scipy as runtime dependencies. Active maintenance—last release 40 days ago, repository actively developed with recent commits.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install datasketch
from datasketch import MinHash
m1 = MinHash()
m1.update(b'apple')
m1.update(b'banana')
m2 = MinHash()
m2.update(b'banana')
m2.update(b'cherry')
similarity = m1.jaccard(m2)
print(f"Jaccard similarity: {similarity}")
Requires Python 3.9 or above; numpy and scipy must be installed (pip handles this automatically).
Verify before relying
- Whether version 2.0.0's breaking changes to MinHash serialization format significantly impact existing deployments or are easily managed via the legacy scheme option.
- Performance characteristics of the new affine32 scheme versus legacy across different dataset sizes and similarity distributions.
- Availability and maturity of Redis and Cassandra storage backends for production scale-out scenarios.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — numpy, scipy |
| Maintenance | actively maintained — 40 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,879,885/month — #1,824 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: datasketch-2.0.0-py3-none-any.whl
Keywords: database, datamining
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
datasketchesProvides streaming algorithms (sketches) for…
permissive · top 5,000 on PyPI
HLLEstimates the cardinality (unique count) of…
permissive · top 15,000 on PyPI
rensaRensa computes MinHash signatures for fast…
permissive · top 15,000 on PyPI
whylogs-sketchingProvides Python bindings to Apache…
permissive · top 15,000 on PyPI
madokaMadoka implements a Count-Min sketch data…
permissive · top 15,000 on PyPI
ddsketchDDSketch computes quantiles (percentiles) of…
permissive · top 5,000 on PyPI
mhfpEncodes molecular structures as MinHash…
unclear · top 15,000 on PyPI
pyspark-hnswProvides a PySpark-compatible implementation of…
unclear · top 15,000 on PyPI
usearchUSearch provides approximate nearest-neighbor…
permissive · top 15,000 on PyPI
voyagerVoyager performs fast approximate…
permissive · top 15,000 on PyPI