sparse-dot-topn
This package boosts a sparse matrix multiplication followed by selecting the top-n multiplication
Decision gist · record as of 2026-08-14
Yes. The package solves a genuine performance and memory bottleneck in large-scale sparse matrix operations. It is actively maintained, has no known vulnerabilities, carries a permissive license, and provides convenient pre-built wheels. Install friction is moderate but manageable. Recommended for projects involving large sparse matrix similarity matching or top-n filtering.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- C++ extension is vendored with OpenMP for parallelization; if OpenMP issues arise, omit n_threads argument or see INSTALLATION.md.
- Medium install friction due to C++ extension dependency, but wheels are pre-built for Python 3.9–3.12 on Windows, Linux, and macOS (x86 and ARM).
License · maintenance · safety
permissive license (permissive) — Licensed under Apache Software License (permissive), imposing no significant restrictions on use, modification, or distribution in most contexts.
last release 2025-12-16 (241 days) · last repo commit 2026-08-10 · 425 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 262,316 downloads/mo, #8,376 on PyPI
Alternatives
Verify before relying
pip install sparse_dot_topn
import scipy.sparse as sparse
from sparse_dot_topn import sp_matmul_topn
A = sparse.random(1000, 100, density=0.1, format="csr")
B = sparse.random(100, 2000, density=0.1, format="csr")
C = sp_matmul_topn(A, B, top_n=10)- Whether the 6× speedup claim on Apple M2 Pro generalizes to other hardware platforms and matrix sizes.
- Performance characteristics when threshold and density parameters are tuned for specific use cases.
- Behavior and performance with negative-valued sparse matrices beyond the stated default change.
What it is and what it does
sparse_dot_topn is a Python package that accelerates a common operation in large-scale similarity matching: multiplying two sparse matrices and keeping only the top-n results per row. It wraps a C++ extension (with vendored OpenMP) to perform this combined operation in a single pass, avoiding the memory overhead of computing the full product and then filtering. The package supports CSR, CSC, and COO sparse matrix formats with 32- and 64-bit integer and float data types, and can parallelize across multiple threads.
The main use case is comparing very large feature vectors (e.g., TF-IDF matrices) and selecting the best matches efficiently. It offers optional threshold filtering to discard low-scoring results and density hints to reduce pre-allocated memory. The package is actively maintained, supports modern Python versions (3.9–3.12), and provides pre-built wheels for common platforms, though source installation is possible for architecture-specific optimization.
Use it for
- Find top-10 most similar documents in a corpus by multiplying TF-IDF matrices and retaining only the highest-scoring matches per row.
- Distribute large-scale matrix multiplication across a cluster by splitting matrices into chunks, computing top-n products per chunk, and re-zipping results.
- Reduce memory footprint when comparing high-dimensional embeddings by filtering to top-n results during multiplication rather than storing the full product.
- Parallelize sparse matrix operations across multiple CPU cores to speed up similarity computations on multi-core systems.
- Apply threshold-based filtering during multiplication to discard low-confidence matches and further reduce output size.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package solves a genuine performance and memory bottleneck in large-scale sparse matrix operations. It is actively maintained, has no known vulnerabilities, carries a permissive license, and provides convenient pre-built wheels. Install friction is moderate but manageable. Recommended for projects involving large sparse matrix similarity matching or top-n filtering.
Install
sparse-dot-topn on PyPI
Before you install
Medium install friction due to C++ extension dependency, but wheels are pre-built for Python 3.9–3.12 on Windows, Linux, and macOS (x86 and ARM). Maintenance is active with recent releases and a healthy repository. Installation from wheels is straightforward; source builds require a C++17 compiler.
Requires Python 3.9 or later. C++ extension is vendored with OpenMP for parallelization; if OpenMP issues arise, omit n_threads argument or see INSTALLATION.md.
License in practice
Licensed under Apache Software License (permissive), imposing no significant restrictions on use, modification, or distribution in most contexts.
Quickstart
pip install sparse_dot_topn
import scipy.sparse as sparse
from sparse_dot_topn import sp_matmul_topn
A = sparse.random(1000, 100, density=0.1, format="csr")
B = sparse.random(100, 2000, density=0.1, format="csr")
C = sp_matmul_topn(A, B, top_n=10)
Verify before relying
- Whether the 6× speedup claim on Apple M2 Pro generalizes to other hardware platforms and matrix sizes.
- Performance characteristics when threshold and density parameters are tuned for specific use cases.
- Behavior and performance with negative-valued sparse matrices beyond the stated default change.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 3 packagesnumpyscipypsutil |
| Maintenance | Actively maintained 241 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 262,316 / month, #8,376 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 |
Evidence: sparse_dot_topn-1.2.0-cp310-cp310-macosx_12_0_arm64.whl; sparse_dot_topn-1.2.0-cp310-cp310-macosx_12_0_x86_64.whl; sparse_dot_topn-1.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; sparse_dot_topn-1.2.0-cp310-cp310-win_amd64.whl; sparse_dot_topn-1.2.0-cp311-cp311-macosx_12_0_arm64.whl; sparse_dot_topn-1.2.0-cp311-cp311-macosx_12_0_x86_64.whl; sparse_dot_topn-1.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; sparse_dot_topn-1.2.0-cp311-cp311-win_amd64.whl; sparse_dot_topn-1.2.0-cp312-abi3-macosx_12_0_arm64.whl; sparse_dot_topn-1.2.0-cp312-abi3-macosx_12_0_x86_64.whl; sparse_dot_topn-1.2.0-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; sparse_dot_topn-1.2.0-cp312-abi3-win_amd64.whl; sparse_dot_topn-1.2.0-cp39-cp39-macosx_12_0_arm64.whl; sparse_dot_topn-1.2.0-cp39-cp39-macosx_12_0_x86_64.whl; sparse_dot_topn-1.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; sparse_dot_topn-1.2.0-cp39-cp39-win_amd64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “sparse matrix multiplication top-n”
- sparse-dot-topnPerforms fast sparse matrix multiplication with integrated top-n…
- nvidia-cusparselt-cu13Provides NVIDIA's CUDA library for high-performance sparse…
- nvidia-cusparselt-cu12Provides NVIDIA's cuSPARSELt CUDA library for high-performance sparse…
Give your agent the search over MCP, or paste the wish link into any chat.
More Mathematics packages
NetworkX provides data structures and algorithms for creating, analyzing, and manipulating graphs and networks, supporting everything from simple undirected graphs to complex directed and weighted networks.
kiwisolver is a Python binding to a fast C++ implementation of the Cassowary constraint solver, enabling you to solve systems of linear constraints and inequalities.
Install it if you need to solve constraint systems; skip it if you only need simple linear algebra.
SymPy is a Python library for symbolic mathematics, performing algebraic manipulation, calculus, equation solving, and mathematical expression simplification without numerical approximation.
ContourPy calculates contours of 2D quadrilateral grids using C++11 algorithms wrapped in Python, offering serial and multithreaded implementations without requiring Matplotlib as a dependency.
PyTorch provides GPU-accelerated tensor computation and automatic differentiation for building and training deep neural networks in Python.
onnxruntime loads and executes Open Neural Network Exchange (ONNX) models with a focus on inference performance across CPUs and accelerators.
Install it if you have ONNX models to run in production or development.
See also nvidia-cusparselt-cu12 · nvidia-cusparselt-cu13 · tabmat · bytesparse · nvidia-cusparse · nvidia-cusparse-cu12 · spglm · qdldl · anndata · fast-array-utils