numexpr 2.14.1


pip install numexpr

  Latest version

Released: Oct 13, 2025


Meta
Author: David M. Cooke, Francesc Alted, and others
Maintainer: Blosc Development Team
Requires Python: >=3.10

Classifiers

Development Status
  • 6 - Mature

Intended Audience
  • Developers
  • Information Technology
  • Science/Research

Programming Language
  • Python :: 3
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14

Topic
  • Software Development :: Libraries :: Python Modules

Operating System
  • Microsoft :: Windows
  • Unix
Author:

David M. Cooke, Francesc Alted, and others.

Maintainer:

Francesc Alted

Contact:
faltet@gmail.com
URL:

https://github.com/pydata/numexpr

Documentation:

http://numexpr.readthedocs.io/en/latest/

GitHub Actions:

actions

PyPi:

version

DOI:

doi

readthedocs:

docs

What is NumExpr?

NumExpr is a fast numerical expression evaluator for NumPy. With it, expressions that operate on arrays (like '3*a+4*b') are accelerated and use less memory than doing the same calculation in Python.

In addition, its multi-threaded capabilities can make use of all your cores – which generally results in substantial performance scaling compared to NumPy.

Last but not least, numexpr can make use of Intel’s VML (Vector Math Library, normally integrated in its Math Kernel Library, or MKL). This allows further acceleration of transcendent expressions.

How NumExpr achieves high performance

The main reason why NumExpr achieves better performance than NumPy is that it avoids allocating memory for intermediate results. This results in better cache utilization and reduces memory access in general. Due to this, NumExpr works best with large arrays.

NumExpr parses expressions into its own op-codes that are then used by an integrated computing virtual machine. The array operands are split into small chunks that easily fit in the cache of the CPU and passed to the virtual machine. The virtual machine then applies the operations on each chunk. It’s worth noting that all temporaries and constants in the expression are also chunked. Chunks are distributed among the available cores of the CPU, resulting in highly parallelized code execution.

The result is that NumExpr can get the most of your machine computing capabilities for array-wise computations. Common speed-ups with regard to NumPy are usually between 0.95x (for very simple expressions like 'a + 1') and 4x (for relatively complex ones like 'a*b-4.1*a > 2.5*b'), although much higher speed-ups can be achieved for some functions and complex math operations (up to 15x in some cases).

NumExpr performs best on matrices that are too large to fit in L1 CPU cache. In order to get a better idea on the different speed-ups that can be achieved on your platform, run the provided benchmarks.

Installation

From wheels

NumExpr is available for install via pip for a wide range of platforms and Python versions (which may be browsed at: https://pypi.org/project/numexpr/#files). Installation can be performed as:

pip install numexpr

If you are using the Anaconda or Miniconda distribution of Python you may prefer to use the conda package manager in this case:

conda install numexpr

From Source

On most *nix systems your compilers will already be present. However if you are using a virtual environment with a substantially newer version of Python than your system Python you may be prompted to install a new version of gcc or clang.

For Windows, you will need to install the Microsoft Visual C++ Build Tools (which are free) first. The version depends on which version of Python you have installed:

https://wiki.python.org/moin/WindowsCompilers

For Python 3.6+ simply installing the latest version of MSVC build tools should be sufficient. Note that wheels found via pip do not include MKL support. Wheels available via conda will have MKL, if the MKL backend is used for NumPy.

See requirements.txt for the required version of NumPy.

NumExpr is built in the standard Python way:

pip install [-e] .

You can test numexpr with:

python -c "import numexpr; numexpr.test()"

Do not test NumExpr in the source directory or you will generate import errors.

Enable Intel® MKL support

NumExpr includes support for Intel’s MKL library. This may provide better performance on Intel architectures, mainly when evaluating transcendental functions (trigonometrical, exponential, …).

If you have Intel’s MKL, copy the site.cfg.example that comes with the distribution to site.cfg and edit the latter file to provide correct paths to the MKL libraries in your system. After doing this, you can proceed with the usual building instructions listed above.

Pay attention to the messages during the building process in order to know whether MKL has been detected or not. Finally, you can check the speed-ups on your machine by running the bench/vml_timing.py script (you can play with different parameters to the set_vml_accuracy_mode() and set_vml_num_threads() functions in the script so as to see how it would affect performance).

Usage

>>> import numpy as np
>>> import numexpr as ne

>>> a = np.arange(1e6)   # Choose large arrays for better speedups
>>> b = np.arange(1e6)

>>> ne.evaluate("a + 1")   # a simple expression
array([  1.00000000e+00,   2.00000000e+00,   3.00000000e+00, ...,
         9.99998000e+05,   9.99999000e+05,   1.00000000e+06])

>>> ne.evaluate("a * b - 4.1 * a > 2.5 * b")   # a more complex one
array([False, False, False, ...,  True,  True,  True], dtype=bool)

>>> ne.evaluate("sin(a) + arcsinh(a/b)")   # you can also use functions
array([        NaN,  1.72284457,  1.79067101, ...,  1.09567006,
        0.17523598, -0.09597844])

>>> s = np.array([b'abba', b'abbb', b'abbcdef'])
>>> ne.evaluate("b'abba' == s")   # string arrays are supported too
array([ True, False, False], dtype=bool)

Free-threading support

Starting on CPython 3.13 onwards there is a new distribution that disables the Global Interpreter Lock (GIL) altogether, thus increasing the performance yields under multi-threaded conditions on a single interpreter, as opposed to having to use multiprocessing.

Whilst numexpr has been demonstrated to work under free-threaded CPython, considerations need to be taken when using numexpr native parallel implementation vs using Python threads directly in order to prevent oversubscription, we recommend either using the main CPython interpreter thread to spawn multiple C threads using the parallel numexpr API, or spawning multiple CPython threads that do not use the parallel API.

For more information about free-threaded CPython, we recommend visiting the following community Wiki <https://py-free-threading.github.io/>

Documentation

Please see the official documentation at numexpr.readthedocs.io. Included is a user guide, benchmark results, and the reference API.

Authors

Please see AUTHORS.txt.

License

NumExpr is distributed under the MIT license.

2.14.1 Oct 13, 2025
2.14.0 Oct 13, 2025
2.13.1 Sep 30, 2025
2.13.0 Sep 24, 2025
2.12.1 Sep 11, 2025
2.12.0 Sep 10, 2025
2.11.0 Jun 09, 2025
2.10.2 Nov 23, 2024
2.10.1 Jun 20, 2024
2.10.0 Apr 02, 2024
2.9.0 Jan 26, 2024
2.8.8 Dec 11, 2023
2.8.7 Sep 26, 2023
2.8.6 Sep 12, 2023
2.8.5 Aug 06, 2023
2.8.4 Oct 26, 2022
2.8.3 Jun 25, 2022
2.8.1 Dec 10, 2021
2.8.0 Dec 02, 2021
2.7.3 Mar 03, 2021
2.7.2 Dec 29, 2020
2.7.1 Jan 05, 2020
2.7.0 Aug 14, 2019
2.6.9 Dec 21, 2018
2.6.8 Aug 19, 2018
2.6.7 Aug 12, 2018
2.6.6 Jul 16, 2018
2.6.6.dev0 May 01, 2018
2.6.5 May 01, 2018
2.6.4 Sep 15, 2017
2.6.3 Sep 14, 2017
2.6.2 Jan 29, 2017
2.6.1 Jul 17, 2016
2.6.0 Jun 01, 2016
2.5.2 Apr 07, 2016
2.5.1 Mar 31, 2016
2.5 Feb 06, 2016
2.4.6 Nov 02, 2015
2.4.5 Nov 02, 2015
2.4.4 Sep 14, 2015
2.4.3 Apr 27, 2015
2.4.2 Apr 22, 2015
2.4.1 Apr 14, 2015
2.4 Apr 06, 2014
2.4rc2
2.4rc1
2.3.1 Feb 18, 2014
2.3 Jan 24, 2014
2.3rc1
2.2.2 Sep 27, 2013
2.2.1 Sep 08, 2013
2.1 Apr 27, 2013
2.0.1 May 03, 2013
1.4.2 Jan 25, 2011
1.4.1 Oct 20, 2010
1.4 Aug 02, 2010
1.3.1 Jun 23, 2009
1.3 Jun 02, 2009
1.1.1 Jan 23, 2009
1.4.win32 Aug 01, 2010
1.4.win Aug 01, 2010
1.4.2.win32 Jan 25, 2011
1.4.2.win Jan 25, 2011
1.4.1.win32 Oct 20, 2010
1.4.1.win Oct 20, 2010
1.3.win32 Jun 02, 2009
1.3.1.win32 Jun 23, 2009
1.1.1.win32 Jan 23, 2009

Wheel compatibility matrix

Platform CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython (additional flags: t) 3.13 CPython (additional flags: t) 3.14
macosx_10_13_x86_64
macosx_10_9_x86_64
macosx_11_0_arm64
manylinux_2_27_aarch64
manylinux_2_27_x86_64
manylinux_2_28_aarch64
manylinux_2_28_x86_64
musllinux_1_2_aarch64
musllinux_1_2_x86_64
win32
win_amd64

Files in release

numexpr-2.14.1-cp310-cp310-macosx_10_9_x86_64.whl (159.4KiB)
numexpr-2.14.1-cp310-cp310-macosx_11_0_arm64.whl (148.5KiB)
numexpr-2.14.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (438.9KiB)
numexpr-2.14.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (429.9KiB)
numexpr-2.14.1-cp310-cp310-musllinux_1_2_aarch64.whl (1.3MiB)
numexpr-2.14.1-cp310-cp310-musllinux_1_2_x86_64.whl (1.4MiB)
numexpr-2.14.1-cp310-cp310-win32.whl (162.9KiB)
numexpr-2.14.1-cp310-cp310-win_amd64.whl (156.3KiB)
numexpr-2.14.1-cp311-cp311-macosx_10_9_x86_64.whl (159.4KiB)
numexpr-2.14.1-cp311-cp311-macosx_11_0_arm64.whl (148.5KiB)
numexpr-2.14.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (440.6KiB)
numexpr-2.14.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (431.7KiB)
numexpr-2.14.1-cp311-cp311-musllinux_1_2_aarch64.whl (1.4MiB)
numexpr-2.14.1-cp311-cp311-musllinux_1_2_x86_64.whl (1.4MiB)
numexpr-2.14.1-cp311-cp311-win32.whl (162.9KiB)
numexpr-2.14.1-cp311-cp311-win_amd64.whl (156.3KiB)
numexpr-2.14.1-cp312-cp312-macosx_10_13_x86_64.whl (159.0KiB)
numexpr-2.14.1-cp312-cp312-macosx_11_0_arm64.whl (148.6KiB)
numexpr-2.14.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (441.9KiB)
numexpr-2.14.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (433.2KiB)
numexpr-2.14.1-cp312-cp312-musllinux_1_2_aarch64.whl (1.4MiB)
numexpr-2.14.1-cp312-cp312-musllinux_1_2_x86_64.whl (1.4MiB)
numexpr-2.14.1-cp312-cp312-win32.whl (163.1KiB)
numexpr-2.14.1-cp312-cp312-win_amd64.whl (156.4KiB)
numexpr-2.14.1-cp313-cp313-macosx_10_13_x86_64.whl (159.0KiB)
numexpr-2.14.1-cp313-cp313-macosx_11_0_arm64.whl (148.6KiB)
numexpr-2.14.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (445.2KiB)
numexpr-2.14.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (436.1KiB)
numexpr-2.14.1-cp313-cp313-musllinux_1_2_aarch64.whl (1.4MiB)
numexpr-2.14.1-cp313-cp313-musllinux_1_2_x86_64.whl (1.4MiB)
numexpr-2.14.1-cp313-cp313-win32.whl (163.1KiB)
numexpr-2.14.1-cp313-cp313-win_amd64.whl (156.4KiB)
numexpr-2.14.1-cp313-cp313t-macosx_10_13_x86_64.whl (159.7KiB)
numexpr-2.14.1-cp313-cp313t-macosx_11_0_arm64.whl (149.3KiB)
numexpr-2.14.1-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (455.1KiB)
numexpr-2.14.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (446.2KiB)
numexpr-2.14.1-cp313-cp313t-musllinux_1_2_aarch64.whl (1.4MiB)
numexpr-2.14.1-cp313-cp313t-musllinux_1_2_x86_64.whl (1.4MiB)
numexpr-2.14.1-cp313-cp313t-win32.whl (163.7KiB)
numexpr-2.14.1-cp313-cp313t-win_amd64.whl (157.3KiB)
numexpr-2.14.1-cp314-cp314-macosx_10_13_x86_64.whl (159.0KiB)
numexpr-2.14.1-cp314-cp314-macosx_11_0_arm64.whl (148.7KiB)
numexpr-2.14.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (445.2KiB)
numexpr-2.14.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (436.0KiB)
numexpr-2.14.1-cp314-cp314-musllinux_1_2_aarch64.whl (1.4MiB)
numexpr-2.14.1-cp314-cp314-musllinux_1_2_x86_64.whl (1.4MiB)
numexpr-2.14.1-cp314-cp314-win32.whl (164.9KiB)
numexpr-2.14.1-cp314-cp314-win_amd64.whl (158.8KiB)
numexpr-2.14.1-cp314-cp314t-macosx_10_13_x86_64.whl (159.7KiB)
numexpr-2.14.1-cp314-cp314t-macosx_11_0_arm64.whl (149.3KiB)
numexpr-2.14.1-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (455.3KiB)
numexpr-2.14.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (446.4KiB)
numexpr-2.14.1-cp314-cp314t-musllinux_1_2_aarch64.whl (1.4MiB)
numexpr-2.14.1-cp314-cp314t-musllinux_1_2_x86_64.whl (1.4MiB)
numexpr-2.14.1-cp314-cp314t-win32.whl (165.5KiB)
numexpr-2.14.1-cp314-cp314t-win_amd64.whl (159.8KiB)
numexpr-2.14.1.tar.gz (116.6KiB)
Extras: None
Dependencies:
numpy (>=1.23.0)