--- id: bottleneck version: "1.6.0" license: Simplified BSD license_treatment: permissive maintenance: active --- # Bottleneck — Fast NumPy array functions written in C License: permissive · Maintenance: active · Downloads: 10.9M/mo ## 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 above — 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 pip install bottleneck uv add bottleneck 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_current - Install friction: medium - Maintenance: active - Downloads: 10.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags fast numpy array operations, nan-aware array functions, moving window calculations, accelerated numpy functions, bottleneck nanmean nansum, numpy performance optimization, rolling window statistics, performance-optimization, numpy-acceleration, time-series [View on SkillFed](https://skillfed.io/packages/bottleneck) · [View on PyPI](https://pypi.org/project/bottleneck/)