Repolode
pydata

pydata/numexpr

Fast NumPy array expression evaluator that computes expressions like 3*a+4*b in chunks, using less memory and multiple cores.

Stars
2,544
Forks
233
Open issues
18
Last commit
7 days ago

What is it?

NumExpr evaluates numerical expressions on NumPy arrays, such as '3*a+4*b', faster and with less memory than computing the same thing in plain Python. It avoids allocating temporary arrays for intermediate results and processes the data in small chunks that fit in CPU cache.

The chunks are distributed across available CPU cores, so calculations scale across multiple threads. Expressions can use common math functions and string array comparisons. Intel MKL/VML support can further accelerate transcendental functions when built against MKL.

Speed-ups over NumPy depend on the expression and array size, and the project notes they are typically largest for large arrays and complex expressions.

Key features

  • 01Evaluates array expressions without allocating intermediate temporaries.
  • 02Splits work into cache-sized chunks distributed across CPU cores.
  • 03Supports common math functions and string array comparisons.
  • 04Optional Intel MKL/VML acceleration for transcendental functions.
  • 05Installable with pip or conda.

Use cases

  • Speeding up large element-wise calculations on NumPy arrays.
  • Filtering or computing conditions over big arrays, as in Pandas or PyTables queries.
  • Reducing memory use in array-heavy numerical code.

Quick start

  1. 1

    Install from PyPI with pip

    pip install numexpr
  2. 2

    Or install with conda if you use Anaconda or Miniconda

    conda install numexpr
  3. 3

    Evaluate an expression on NumPy arrays

    python -c "import numpy as np, numexpr as ne; a = np.arange(1e6); print(ne.evaluate('a + 1'))"

Things to know

  • Speed-ups are small for very simple expressions and work best on large arrays.
  • Pip wheels do not include Intel MKL support; MKL is only in conda builds when NumPy uses MKL.
  • The project is seeking funding for its future, so long-term maintenance is uncertain.

Topics

FAQ

What is numexpr?
Fast NumPy array expression evaluator that computes expressions like 3*a+4*b in chunks, using less memory and multiple cores. NumExpr evaluates numerical expressions on NumPy arrays, such as '3*a+4*b', faster and with less memory than computing the same thing in plain Python. It avoids allocating temporary arrays for intermediate results and processes the data in small chunks that fit in CPU cache.
Is numexpr free to use? What license does it have?
numexpr is open source under the MIT license. Check the license terms before using it in commercial products.
Is numexpr still maintained?
Actively maintained. The last commit to numexpr was on Oct 13, 2026.
What can I use numexpr for?
Speeding up large element-wise calculations on NumPy arrays. Filtering or computing conditions over big arrays, as in Pandas or PyTables queries. Reducing memory use in array-heavy numerical code.
How do I install numexpr?
Install from PyPI with pip: pip install numexpr Or install with conda if you use Anaconda or Miniconda: conda install numexpr Evaluate an expression on NumPy arrays: python -c "import numpy as np, numexpr as ne; a = np.arange(1e6); print(ne.evaluate('a + 1'))"
Where can I get numexpr?
The source code and installation instructions are on GitHub: https://github.com/pydata/numexpr

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects