skillfed

Bottleneck

Fast NumPy array functions written in C

bottleneck v1.6.0 10.9M downloads/30d#1,428 on PyPI1,181
Permissive license Simplified BSD Active released

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 bottleneck

uv

uv add bottleneck

poetry

poetry add bottleneck

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: Financial and Insurance IndustryIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Free Threading :: 2 - BetaTopic :: Scientific/Engineering

Tags

fast numpy array operationsnan-aware array functionsmoving window calculationsaccelerated numpy functionsbottleneck nanmean nansumnumpy performance optimizationrolling window statistics
performance-optimizationnumpy-accelerationtime-series

More Scientific/Engineering packages