numpy
Fundamental package for array computing in Python
Python lists are general-purpose and slow for numerical work โ each element is a Python object with overhead, and there's no vectorised math. Before NumPy, scientific computing in Python meant writing slow loops or reaching for C extensions manually. NumPy solved this by providing a typed, contiguous array backed by optimised C and Fortran code.
Think of a NumPy ndarray as a typed, multi-dimensional grid of numbers stored contiguously in memory. Operations on the array run in compiled C โ adding two arrays of a million numbers is a single C loop, not a million Python function calls. The key insight is 'vectorise your thinking': replace loops with operations on whole arrays.
Install numpy
pip install numpy
import numpyUse it when
Use NumPy any time you're doing numerical computation: matrix math, statistics, signal processing, image data as pixel arrays, or feeding data into ML libraries. It's the foundation most scientific Python libraries (pandas, scipy, PyTorch) are built on.
Skip it when
NumPy is not for general-purpose data manipulation with mixed types or strings โ use pandas DataFrames there. For very large datasets that don't fit in RAM, look at Dask or CuPy (GPU arrays).
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.