numthreads

Set the number of threads used by OpenBLAS, MKL, OMP, NumExpr, and Accelerate

PyPI Build Status CodeCov GitHub Repo stars Documentation

numthreads is a really tiny and simple Python package designed to set the number of threads for various computing libraries including OpenBLAS, Intel’s Math Kernel Library (MKL), OpenMP, NumExpr, and Accelerate. The number of threads can be set via the command line or in Python code. The performance of many numerical algorithms varies significantly based on the number of threads employed. While increasing the number of threads can often accelerate these algorithms, it’s not always the case. In some instances, using more threads may actually impede computational efficiency. Therefore, it’s important to be able to easily set the number of threads used by these libraries.

  • Simple and straightforward command-line interface.

  • Sets thread count for OpenBLAS, MKL, OpenMP, NumExpr, and Accelerate.

  • Context manager support for temporary thread setting in Python code.

  • Cross-platform compatibility (Linux, macOS, Windows).

  • Tiny (≤7KB) and no dependencies.