Bottleneck
Fast NumPy array functions written in C
What it is and what it does
Bottleneck is a C-accelerated library that reimplements common NumPy array operations to run significantly faster, particularly when working with NaN values or performing moving-window calculations. It wraps NumPy arrays and provides drop-in replacements for functions like nanmean, nansum, nanstd, nanmin, nanmax, median, and a suite of moving-window operations (move_mean, move_sum, move_std, move_median, etc.).
The package is designed for workflows where you repeatedly call these operations on large arrays—finance, time-series analysis, and scientific computing are typical use cases. It only accelerates int32, int64, float32, and float64 dtypes; other dtypes fall back to slower unaccelerated paths. Installation is straightforward on common platforms thanks to pre-built binary wheels, though it requires a C compiler if building from source.
Use it for:
- Computing statistics on financial time series with missing data (NaN values) where speed matters.
- Calculating rolling/moving averages, sums, and standard deviations on large arrays.
- Finding min/max and ranking operations on arrays with NaN values faster than NumPy.
- Accelerating scientific data processing pipelines that repeatedly call reduction functions.
- Replacing slow NumPy operations in data analysis workflows without changing code logic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Bottleneck provides fast NumPy array functions written in C, accelerating operations like nanmean, nansum, moving window calculations, and ranking on arrays with NaN values.
Yes, if you work with NumPy arrays and frequently call NaN-aware or moving-window operations on large datasets. The permissive license and active maintenance make it low-risk. Install friction is medium due to compiled extensions, but binary wheels cover most platforms. Skip it if your arrays are small, you rarely use these specific functions, or you work exclusively with non-numeric dtypes.
Install
bottleneck on PyPI
pip
pip install bottleneckuv
uv add bottleneckpoetry
poetry add bottleneckInstalling Bottleneck
Before you install
Medium install friction due to compiled C extensions; however, binary wheels are available for common platforms (Python 3.10–3.12 on Linux, macOS, Windows), making installation straightforward in most environments. The package is actively maintained with a recent release.
License in practice
Distributed under a Simplified BSD license (permissive), allowing use in commercial and private projects with minimal restrictions.
Quickstart
pip install bottleneck
import bottleneck as bn
import numpy as np
a = np.array([1, 2, np.nan, 4, 5])
result = bn.nanmean(a) # Returns 3.0
Requires NumPy 1.16.0 or later; Python 3.10 or newer for current binary wheels.
Verify before relying
- Actual performance gains vary by array size, dtype, and operation—the description shows benchmark ratios but real-world speedup depends on your specific use case.
Package facts
| License | Simplified BSD (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 340 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,889,451/month — #1,428 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: bottleneck-1.6.0-cp310-cp310-macosx_11_0_arm64.whl; bottleneck-1.6.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; bottleneck-1.6.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; bottleneck-1.6.0-cp310-cp310-musllinux_1_2_aarch64.whl; bottleneck-1.6.0-cp310-cp310-musllinux_1_2_x86_64.whl; bottleneck-1.6.0-cp310-cp310-win32.whl; bottleneck-1.6.0-cp310-cp310-win_amd64.whl; bottleneck-1.6.0-cp311-cp311-macosx_11_0_arm64.whl; bottleneck-1.6.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; bottleneck-1.6.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; bottleneck-1.6.0-cp311-cp311-musllinux_1_2_aarch64.whl; bottleneck-1.6.0-cp311-cp311-musllinux_1_2_x86_64.whl; bottleneck-1.6.0-cp311-cp311-win32.whl; bottleneck-1.6.0-cp311-cp311-win_amd64.whl; bottleneck-1.6.0-cp312-cp312-macosx_11_0_arm64.whl; bottleneck-1.6.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; bottleneck-1.6.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; bottleneck-1.6.0-cp312-cp312-musllinux_1_2_aarch64.whl; bottleneck-1.6.0-cp312-cp312-musllinux_1_2_x86_64.whl; bottleneck-1.6.0-cp312-cp312-win32.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
numbaggNumbagg provides fast N-dimensional aggregation…
unclear · top 5,000 on PyPI
window-opsProvides numba-optimized window operations…
permissive · top 15,000 on PyPI
numpy-groupiesProvides optimized group-indexing operations on…
permissive · top 15,000 on PyPI
antropyAntroPy computes entropy and fractal dimension…
permissive · top 15,000 on PyPI
albucoreAlbucore provides optimized atomic image…
permissive · top 5,000 on PyPI
jenkspyComputes optimal class boundaries for numerical…
permissive · top 15,000 on PyPI
fast-array-utilsConverts and computes statistics across sparse,…
copyleft · top 15,000 on PyPI
numexprNumExpr evaluates numerical expressions on…
permissive · top 5,000 on PyPI
numpy-minmaxFinds the minimum and maximum values in a NumPy…
permissive · top 15,000 on PyPI
sparseProvides multi-dimensional sparse array data…
permissive · top 5,000 on PyPI