← New search

Other meanings of NumPy

Scientific Computing

NumPy

NumPy is a fundamental Python library for numerical computing, providing a powerful N-dimensional array object, broadcasting functions, and tools for integrating C/C++ and Fortran code. It is the foundation of the scientific Python ecosystem, underpinning libraries such as SciPy, pandas, and scikit-learn.

2006
First release (as NumPy, successor to Numeric and Numarray)
~30k
Stars on GitHub (as of 2025)
~1.5M
Approximate weekly downloads on PyPI (as of 2025)
1

Core features and design

The central object in NumPy is the ndarray, a homogeneous N-dimensional array that supports vectorized operations, enabling efficient computation without explicit loops. Arrays are stored in contiguous memory blocks, and operations are implemented in optimized C, making NumPy orders of magnitude faster than pure Python for large data. Key features include broadcasting (performing element-wise operations on arrays of different shapes), universal functions (ufuncs) that operate element-wise, and advanced indexing and slicing. NumPy also provides linear algebra routines, Fourier transforms, and random number generation.1

2

History and evolution

NumPy was created by Travis Oliphant in 2005 by merging the earlier Numeric and Numarray libraries, with the first release in 2006. It was designed to combine the best features of both predecessors while addressing their limitations. Since then, NumPy has become the de facto standard for array computing in Python, with a stable API and a strong community. The project is now part of the NumFOCUS organization and is maintained by a team of core developers. Notable milestones include the introduction of the numpy.random module overhaul in version 1.17 and the adoption of a new array function protocol in version 1.17.2

3

Ecosystem and applications

NumPy serves as the foundation for a vast ecosystem of scientific and data analysis libraries. SciPy builds on NumPy for advanced scientific computing, pandas uses NumPy arrays for data structures, and scikit-learn relies on NumPy for machine learning algorithms. Beyond these, NumPy is used in fields ranging from astronomy (Astropy) to bioinformatics (Biopython) and image processing (scikit-image). Its array interface is also implemented by other libraries like TensorFlow and PyTorch to facilitate interoperability. NumPy's influence extends to GPU computing through libraries like CuPy, which provides a NumPy-compatible API for CUDA.

4

Lesser-known aspects

NumPy includes several lesser-known features that are valuable for advanced users. The numpy.lib.stride_tricks module allows creating views with custom strides, enabling efficient sliding window operations. The numpy.ctypeslib facilitates interaction with C libraries. NumPy also supports structured arrays and record arrays for heterogeneous data, and the numpy.ma module provides masked arrays for handling missing data. A notable edge case is the np.matrix subclass, which is discouraged but still present; it enforces matrix semantics and can lead to confusion. Additionally, NumPy's np.einsum function implements Einstein summation, a powerful tool for tensor operations. The library also includes a set of numpy.testing utilities for writing unit tests.3

5

Performance and optimization

NumPy's performance is achieved through vectorization and memory locality, but users can further optimize by avoiding unnecessary copies, using in-place operations, and leveraging np.ndarray.view for zero-copy views. The numpy.vectorize function is often misunderstood: it does not improve performance, as it is essentially a loop. For large-scale computations, NumPy can be combined with Numba (a JIT compiler) or Cython to accelerate critical sections. The np.dot and np.matmul functions are optimized to use BLAS libraries like OpenBLAS or MKL, which can be selected at build time. NumPy also supports memory-mapped arrays (np.memmap) for handling datasets larger than RAM.

Glossary

ndarray
The core N-dimensional array object in NumPy, providing fast vectorized operations.
Broadcasting
A set of rules that allow NumPy to perform element-wise operations on arrays of different shapes.
ufunc
Universal function; a vectorized function that operates element-wise on arrays.
Stride
The number of bytes to step in each dimension when traversing an array.

NumPy is released under the BSD license and is developed and maintained by a community of volunteers.