NumPy provides the N-dimensional array (ndarray) and fast element-wise maths on it. SciPy is a collection of scientific algorithms, such as optimisation, integration, statistics, signal processing and sparse matrices, that operate on NumPy arrays. In practice you install and import both: NumPy holds the data, SciPy does the specialised computation.
This question is about Python scientific computing, not web development, so the examples below use current NumPy 2.x and SciPy 1.x APIs.
NumPy is the foundation of the Python numerical stack. Its core is the ndarray, a typed, contiguous block of memory that lets operations run in compiled code instead of Python loops.
float64, int32, and so on).np.sin, np.add).np.linalg), random numbers (np.random.default_rng), FFT (np.fft) and array manipulation.SciPy builds on NumPy and adds higher-level algorithms, many of them wrappers around battle-tested C, C++ and Fortran libraries. It is organised into submodules that you import individually:
| Submodule | Purpose |
|---|---|
scipy.optimize | Minimisation, root finding, curve fitting |
scipy.integrate | Numerical integration and ODE solvers |
scipy.interpolate | Interpolation and splines |
scipy.linalg | Extended linear algebra (decompositions, solvers) |
scipy.stats | Distributions and statistical tests |
scipy.signal | Filtering and signal processing |
scipy.sparse | Sparse matrices and solvers |
scipy.spatial | KD-trees, distances, convex hulls |
SciPy depends on NumPy and uses ndarray as its data type for almost every function, so there is no conversion step. Historically SciPy re-exported many NumPy functions in its top-level namespace; those aliases were deprecated and removed, so import NumPy functions from numpy and SciPy functions from the relevant scipy submodule.
Some features exist in both, and the SciPy version is generally the more complete one:
numpy.linalg offers common operations. scipy.linalg adds more decompositions, always links to BLAS and LAPACK, and supports extra routines.numpy.fft and scipy.fft both compute transforms. scipy.fft is the recommended one for new code and offers more options such as multi-threading via the workers argument.Installing SciPy pulls in a compatible NumPy automatically, so one pip command covers both.
Yes. SciPy requires NumPy and takes NumPy arrays as inputs and outputs.
They solve different problems. Both run compiled code, so speed depends on the algorithm. SciPy is not a faster NumPy; it is a larger toolbox.
Start with numpy.linalg for basics. Choose scipy.linalg when you need extra decompositions or solvers it does not offer.
Both are low-level building blocks. Frameworks such as scikit-learn, PyTorch and TensorFlow build on array computing like NumPy's.
NumPy is the array foundation: storage, vectorised maths and broadcasting. SciPy adds scientific algorithms on top of NumPy arrays. Most scientific Python projects install both and import each where it fits.