pypi / numpy
numpy
What changed in numpy 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
216 breaking8 security28 deprecations91 new APIs and options8 performance29 behavior and defaults4 tooling88 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initnumpy 2472 changes
Breaking changes 216
Six-tuple dtype pickle states with versions greater than 1 are rejected.
Casting structured void or subarray dtypes to StringDType now raises TypeError instead of interpreting element bytes as UTF-8.
When a copied fill_value cannot be represented in the new dtype, it resets to that dtype’s default; explicitly supplied fill_value values are still validated and raise as before.
Raises for inputs containing infinities instead of returning garbage results, and fixes hangs for certain such inputs with recent LAPACK implementations.
Casting a fixed-width byte string array with invalid UTF-8 to StringDType now raises TypeError instead of storing invalid bytes.
The struct is opaque for extensions targeting the free-threading-compatible stable ABI, so those extensions can no longer access its fields; the NpyString allocator API remains usable with the descriptor pointer.
The minimum supported GCC version increased from 9.3.0 to 10.3.0, affecting developers building NumPy from source.
The data type alias 'a' has been removed; use 'S' instead.
_add_newdoc_ufunc(ufunc, newdoc) has been removed; assign ufunc.__doc__ instead.
Scalars now export the interface directly and are read-only, rather than exposing an array copy through a __ref entry.
Projects building against NumPy's Cython headers now require Cython 3.0 or newer.
get_array_wrap has been removed.
Windows platforms now require a minimum MSVC 19.35 toolchain, corresponding to Visual Studio 2022 version 17.5 Preview 2 or newer.
For object arrays, imag now returns getattr(element, "imag", 0) elementwise, and the result is read-only.
For object arrays, real now returns getattr(element, "real", element) elementwise, and the result is read-only.
This function has been removed.
Non-integer inputs now raise TypeError.
The re-export of numpy.char.chararray has been removed.
Two-dimensional vectors are no longer supported.
The function now accepts only numpy.ndarray; passing a scalar type raises TypeError.
Addition, subtraction, and integer multiplication now raise OverflowError when results overflow int64 or land on the NaT sentinel.
numpy.distutils has been removed.
Passing None as dtype now raises TypeError.
Unsupported device, dtype, or excessive dimensionality now raises BufferError instead of RuntimeError.
numpy.isreal is affected by the changed object-array imag behavior because it uses arr.imag.
The alias for the standard library math module has been removed.
numpy.linalg.eig now always returns complex arrays, rather than returning values whose type depended on the eigenvalues.
numpy.linalg.eigvals now always returns complex arrays, rather than returning values whose type depended on the eigenvalues.
meshgrid now always returns a tuple, including when sparse is true and copy is false.
Errors in the BTPE sampler's Stirling-series acceptance/rejection step were corrected, so results may differ for the same seed.
Results may differ for the same seed because the BTPE sampler used internally by multinomial had errors corrected.
numpy.row_stack has been removed in favor of numpy.vstack.
Out-of-range Python integers in x or y are no longer silently truncated; they now raise OverflowError.
The C API function now raises OverflowError rather than silently truncating out-of-range Python integers.
NumPy 2.5.0 drops support for Python 3.11; supported Python versions are 3.12–3.14.
recfromtxt and recfromcsv have been removed from numpy.lib._npyio in favor of numpy.genfromtxt.
Copies of structured arrays with identical contiguous dtypes now use memcpy, which may copy padding bytes that were previously left untouched.
Returns rank 0 for empty matrices.
Converting an array with ndim greater than zero to a scalar now raises TypeError; extract a single element first.
The default x86 baseline has been raised to x86-64-v2; builds can set it to none to support older CPUs.
The deprecated, nonfunctional disp function has been removed.
Index preparation now matches ndarray behavior, with stricter validation, corrected IndexError types, and more specific errors; some float and scalar-boolean indices are deprecated.
Sorting with kind='heapsort' now maps to kind='quicksort', potentially changing execution time or unstable argsort order.
The deprecated runtime discovery mechanism has been removed.
The undocumented get_as_parameter method was removed; use _as_parameter_ instead.
The undocumented get_data method was removed; use data instead.
The undocumented get_shape method was removed; use shape instead.
The undocumented get_strides method was removed; use strides instead.
The macro defined in npy_cpu.h has been removed.
When used, NPY_HEAPSORT is mapped to NPY_QUICKSORT.
Deleting numpy from sys.modules and importing it again now fails with ImportError because C extension modules are checked for single import per process.
Type checkers no longer accept start as a keyword argument, though runtime use remains possible.
The style parameter has been removed; arguments following it, such as formatter, are now keyword-only.
The bias argument has been removed because it had no effect.
The ddof argument has been removed because it had no effect.
The deprecated module has been removed; use numpy.fft instead.
Removed in favor of numpy.isin.
The deprecated module has been removed; use numpy.linalg instead.
The delimitor parameter has been removed; use delimiter instead.
The interpolation parameter has been removed; use method instead.
The interpolation parameter has been removed; use method instead.
Removed; use next(ndindex) instead.
The interpolation parameter has been removed; use method instead.
The interpolation parameter has been removed; use method instead.
The newshape parameter has been removed; pass the shape positionally or use shape= on newer NumPy versions.
Always returns a copy, including for integer inputs with nonnegative decimals.
The ignored fix_imports parameter has been removed.
Passing a generator directly now raises TypeError; use numpy.fromiter or Python's sum builtin.
Removed; use numpy.trapezoid or scipy.integrate functions instead.
The type alias no longer accepts None; use DTypeLike | None for optional dtype annotations.
Hash-based unique extraction speeds up string arrays substantially, but returned unique values are not guaranteed to be sorted.
Multiplication that would create an unrepresentably large string now raises OverflowError instead of MemoryError.
New x86 CPU feature group representing x86-64-v3 microarchitectures.
New x86 CPU feature group representing x86-64-v4 microarchitectures.
Negative input now raises ValueError.
The function and method now return booleans for object arrays rather than an argument value; use
np.logical_and.reducefor the previous behavior.The function and method now return booleans for object arrays rather than an argument value; use
np.logical_or.reducefor the previous behavior.The C API exports only static inline function versions of array accessors; struct fields can still be used directly, though discouraged.
Removed; migrate to
__array_ufunc__or rely on__array_wrap__, which is called with context in all cases.Out-of-bound axis values now error instead of being treated like
axis=None; useaxis=Noneexplicitly.The default NumPy integer is now 64-bit on all 64-bit systems, including Windows.
The default integer type on Windows is now int64 instead of int32, matching other platforms.
The relaxed strides debug build option configured with this flag has been removed.
The flags value is now stored unsigned, so the aligned dtype struct flag is positive rather than negative; code checking flags manually may need to adapt.
The related ufunc keyword argument was removed; use the
np.errstate()context manager instead.Ambiguous
-mand.pyfcombinations are no longer accepted: multiple.pyffiles raise an error, while using both-mand a.pyfwarns and ignores the-mname.Removed; replace calls with
subprocess.runinvokingpython -m numpy.f2py.The default encoding is now
None; converters receivestrrather thanbytes, and returned values are Unicode strings rather than bytes.This ufunc struct member was removed to simplify improvements to the dispatching system.
The default encoding is now
None, so converters receivestrrather thanbytes; pass encoding explicitly to select behavior.The advanced indexing MapIter and related API were removed.
Assigning to the
.dataattribute of an ndarray is disallowed and raises.This header was removed; replace missing symbols with their prefixed counterparts.
Removed; use
np.asarraywith a proper dtype instead.Raises when
widthis too small.It can no longer be called with Python int, float, or complex instances because cast results must not depend on scalar values.
Removed; replace
np.cast[dtype](arg)withnp.asarray(arg, dtype=dtype).Removed; use
np.complex128instead.Removed; use
np.clongdoubleinstead.Removed from the main namespace; use
np.char.compare_chararraysinstead.Removed; use
np.complex128instead.Removed from the public API.
Support for seven data type string aliases has been removed.
np.dtype(("f8", 1))now returns a shape-1 subarray dtype rather than a non-subarray dtype.Removed from the main namespace.
Removed; use
numpy.promote_typesornumpy.result_typeinstead.Removed; use
np.float64instead.Removed from the main namespace; use
np.rec.format_parserinstead.Removed; use the
np.errstate()context manager instead.Removed; use
np.infinstead.Removed; use
np.infinstead.Removed; use
np.infinstead.Its C definition now matches size_t/Py_ssize_t rather than intptr_t; pointers may no longer fit in an intp typed array on niche platforms.
Removed; use the
issubclassbuiltin instead.Removed; use
np.clongdoubleinstead.Removed; use
np.longdoubleinstead.Removed.
Removed; use
np.asmatrixinstead.Removed; use
np.sort(a, axis=0)instead.Removed; use
np.naninstead.Removed; use
np.dtype(<dtype>).itemsizeinstead.Now available only from
np.lib.npyio.Removed; use
np.roundinstead.Removed from the main namespace; use
ast.literal_evalinstead.Removed from the main namespace.
Removed; use
np.set_printoptionswith a formatter for custom printing.Removed; use
np.complex64instead.Broadcasting when b has one fewer dimension than a now follows the Array API and changes backward-incompatibly; use
np.solve(a, b[..., None])[..., 0]to reconstruct the old behavior.Removed; use
inspect.getsourceinstead.Removed; use
np.bytes_instead.Now available only from
np.lib.Its C definition now matches size_t/Py_ssize_t rather than intptr_t/uintptr_t, which can affect pointer fit on niche platforms.
Removed; use
np.str_instead.Using
NPY_CHARinPyArray_DescrFromType()raises; useNPY_STRING,NPY_UNICODE, orNPY_VSTRINGinstead.This header and its corresponding macros were removed; the notes recommend periodically querying Python signal functions instead.
Removed to avoid confusion.
This macro was removed because it reflected only built-in numeric types and served no internal purpose.
It is now a runtime constant rather than a compile-time constant; stack allocations must use a custom constant and check against it at runtime.
Its value is now 64; uses where it meant
axis=Nonemust instead useNPY_RAVEL_AXIS.NPY_NTYPESwas renamed to clarify that it does not include new built-in DTypes.Use this in conversion helpers and C API functions where
NPY_MAXDIMSpreviously representedaxis=None.The relaxed strides debug build option enabled through this environment variable has been removed.
NumPy 2.0 breaks ABI compatibility: binaries built against NumPy 1.xx will not work with NumPy 2.0.
Underlying C types now use C99 complex types; direct real or imaginary field access is no longer available, and utilities in numpy/npy_math.h should be used.
This deprecated header and its
PyArray_CONSTANTmacros were removed; the notes mention a script to convert them toNPY_CONSTANTversions.Scalars now include type information in their representation, for example np.float64(3.0) instead of 3.0; legacy="1.25" can restore the old behavior for now.
Strings are now true when non-empty and false when empty, matching Python; whitespace is true, and the change affects string-to-boolean casts and np.nonzero.
Unstable sorting methods, including the default method, may return slightly different results because of algorithmic changes and SIMD code.
Unstable sorting methods, including the default method, may return slightly different results because of algorithmic changes and SIMD code.
The experimental submodule has been removed; use the main
numpynamespace for regular usage orarray-api-strictfor compliance testing.copyacceptsNone,True, andFalse;Falsenow raisesValueErrorif a copy is required.copyacceptsNone,True, andFalse;Falsenow raisesValueErrorif a copy is required.When returning a sequence of arrays, this function now returns a tuple of ndarrays instead of a list.
When returning a sequence of arrays, this function now returns a tuple of ndarrays instead of a list.
When returning a sequence of arrays, this function now returns a tuple of ndarrays instead of a list.
This function now returns a tuple of ndarrays instead of a list.
A trailing comma in a dtype string now always creates a structured dtype with a single field.
The context manager and decorator is faster and context safe; it can only be entered once now.
Warnings and exceptions in this module are no longer exposed in the main namespace.
When s[i] is -1, the transform now uses the whole input array along axis i.
The submodule was renamed to
numpy.fft._helperto mark it private; access public functions throughnumpy.fft.FFT routines now calculate natively in float, double, or long double precision according to input precision, and adjust output dtype accordingly.
Now returns a tuple rather than a list, making the return value immutable.
This function now returns a tuple of ndarrays instead of a list.
Integer classes will no longer support conversion of out-of-bounds Python integers to integer arrays; use
np.array(value).astype(dtype)for the desired result.Introduced as a public submodule containing byte_bounds, normalize_axis_tuple, and normalize_axis_index; byte_bounds moved from numpy.lib.utils.
The submodule was renamed to
numpy.linalg._linalgto mark it private; access public functions throughnumpy.linalg.The default
rcondis now machine precision times max(M, N); passrcond=-1for the old behavior.Added as a NumPy integer mapping to C's long; before NumPy 1.24, it aliased Python's int.
This function now returns a tuple of ndarrays instead of a list.
This function now returns a tuple of ndarrays instead of a list.
The legacy="1.25" option can temporarily restore the old scalar representation behavior.
Its buffer size is now tied to numpy.errstate; leaving an errstate context resets the buffer size.
For complex values, sign is now calculated as
z / |z|; zero is returned whenz==0.For multidimensional inputs,
unique_inverseis now shaped so the input can be reconstructed directly withtakeortake_along_axis.Removed; a variable explorer in IDEs such as Spyder or Jupyter Notebook can provide alternatives.
Removed; the notes recommend
PyArray_CopyIntoor, if needed,PyArray_CopyAnyInto.Removed; the notes recommend
PyArray_CopyIntoinstead.This C API macro was removed.
Removed; use standard C string comparison functions.
The
->fslot was removed; usePyDataType_GetArrFuncsto access the functionality.Removed because its use was unclear and its semantics were incorrect in some use cases.
Removed; create a new empty array or use
PyArray_FillWithScalar().Removed; access to cast functions for custom legacy user dtypes is no longer available through this API.
Now requires importing the NumPy API table and is no longer defined in
ndarraytypes.h.A static inline function for importing the NumPy C API table; it checks whether import was already performed and is lightweight when it was.
Removed as misleading and without known use cases.
This macro moved from
ndarraytypes.htonpy_math.h.Removed; use
PyArray_CopyIntoinstead.Removed; use
Py_REFCNTinstead.Custom legacy user dtypes registered with this API require changes to accommodate the ABI break and support both NumPy 1.x and 2.x.
The expired deprecation is finalized and the C function removed.
Removed; use explicit sizes or types, or go through Python strings.
This API is private now; use the Python API if needed.
sizeof(PyArrayMultiIterObject)no longer includes the full size of the object.The deprecation expired and the function was removed; use
tracemallocand thenp.lib.tracemalloc_domaindomain.Use this function to access descriptor alignment unless compiling only with NumPy 2 support.
Access the
c_metadatastructured dtype field through the corresponding function rather than directly.Use this function to access descriptor
elsizeunless compiling only with NumPy 2 support.Access the
fieldsstructured dtype field through the corresponding function rather than directly.Dtype-flag functionality is available only after including
numpy/ndarrayobject.h, because it requiresimport_array().Access dtype flags through this inline function for compatibility with NumPy 1.x and 2.x.
Removed because it had not done anything since at least NumPy 1.7.
Structured dtype fields such as
namesmust now be accessed through functions like this, since those fields do not exist on every descriptor.Dtype-flag functionality is available only after including
numpy/ndarrayobject.h, because it requiresimport_array().Use this function to set descriptor
elsizeunless compiling only with NumPy 2 support.Access the
subarraystructured dtype field through the corresponding function rather than directly.The public and private APIs are clearly split, with a new module structure and each public function available in a single place.
This release supports Python 3.9–3.12.
The
typesanddataarguments are now const-correct; C++ code may be affected.The
typesanddataarguments are now const-correct; C++ code may be affected.The
typesanddataarguments are now const-correct; C++ code may be affected.This C API function was removed.
A static inline function for importing the ufunc API table; it checks whether import was already performed and is lightweight when it was.
The expired deprecation is finalized and the function removed.
Type promotion adopts NEP 50, making promotions depend on input dtypes rather than array data values; mixed-dtype operations may change output dtypes or produce lower precision.
Security 8
Out-of-bounds reads in datetime parsing API errors are avoided.
Setting an array's dtype attribute is deprecated because mutating a shared array is unsafe; use array.view(dtype=new_dtype).
Resizing an array in place is deprecated because mutating a shared array is unsafe; use np.resize instead.
Fixes a heap buffer overflow in timedelta-to-string casts.
Fixes a heap overflow in fixed-width string multiplication.
Setting the strides attribute is deprecated because mutating a shared array is unsafe; create a new view instead.
Setting an array's shape attribute is deprecated; use np.reshape or np.ndarray.reshape to create a new view.
Avoids a segmentation fault in string_expandtabs_length_promoter.
Deprecations 28
The numpy.char.array and numpy.char.asarray functions are deprecated; use numpy.array or numpy.asarray with a string or bytes dtype.
This class is deprecated; use an ndarray with a string or bytes dtype instead.
numpy.ma.round_ is deprecated; use numpy.ma.round instead.
The same-kind cast check now tests whether the result can be cast to out; a DeprecationWarning is issued when it cannot.
Using the generic unit is deprecated, as are operations that implicitly rely on it; specify an explicit unit instead.
Non-integer values for M, k, and N are deprecated.
Non-integer values for k are deprecated.
Inputs other than integers are deprecated.
numpy.typename is deprecated because its returned names were outdated and inconsistent; use numpy.dtype.name instead.
A VisibleDeprecationWarning is emitted when align is not a boolean; pass align as a keyword argument.
numpy.fix is deprecated; use numpy.trunc, which provides identical functionality and follows the Array API standard.
The container class is deprecated and will be removed in a future version.
Passing out positionally is deprecated; pass it by keyword to distinguish the output buffer from inputs.
Deprecated in favor of warnings.catch_warnings, warnings.filterwarnings, pytest.warns, or pytest.filterwarnings.
Calling a ufunc with where but without out now emits a warning; out=None suppresses it.
Implementations must accept
arr, context, return_scalar; support for implementations not accepting all three arguments is deprecated.Use of keyword arguments
xandyis deprecated; pass the first two arguments positionally.The main-namespace chararray is deprecated; importing it from
np.char.chararrayavoids a deprecation warning for now.Deprecated because Python 2 is no longer supported.
Arrays of 2-dimensional vectors are deprecated; use arrays of 3-dimensional vectors instead.
The
np.dtype("a")alias fornp.dtype(np.bytes_)is deprecated; use thenp.dtype("S")alias instead.Deprecated; use
np.isininstead.Deprecated alias; use
np.vstackdirectly.Deprecated; use
np.trapezoidor ascipy.integratefunction instead.Accessing numpy.core now emits a DeprecationWarning; private internals remain accessible through numpy._core without backward-compatibility guarantees.
A single number in parentheses to indicate a sub-array shape is deprecated; use
(2,)ior2iinstead of(2)i.For n-D transforms, using a non-None
swithaxes=Noneis deprecated; pass an explicit sequence of axes to retain current behavior.Passing an array to
scontainingNonevalues is deprecated; pass the corresponding default length or omitsfor defaults on every axis.
New APIs and options 91
The descending keyword enables descending argsorts; NaNs remain at the end, and the feature supports built-in dtypes except void, object, and generic.
User-dtype authors can register dtypes for DLPack export and import.
The descending keyword enables descending sorts; NaNs remain at the end, and the feature supports built-in dtypes except void, object, and generic.
A new polynomial function evaluates polynomials in arbitrary dimensions.
A new C API accessor macro allows accessing a PyArray_Descr field without direct field access.
User-defined dtypes can implement custom sorting and argsorting with ArrayMethod specs registered through PyUFunc_AddLoopsFromSpecs.
The same_value casting option verifies that values round-trip without changing; it raises ValueError if casting changes any value.
New DType API slot lets dtype implementations provide constants such as machine limits and special values, enabling numpy.finfo support.
New NPY_SORTKIND enum name for default sorting, with the same value as NPY_QUICKSORT.
New NPY_SORTKIND enum name for descending sort; it is not yet implemented.
New NPY_SORTKIND enum name indicating that sorting must be stable.
NumPy checks this protocol when converting objects to dtypes through np.dtype or dtype arguments, allowing dtype-like objects to define conversion explicitly.
The ndmax option limits the maximum dimensions created from nested sequences, useful for preserving nested structures as object elements.
The pad_width argument now accepts a dictionary.
Accepts multiple axes.
The axis argument now accepts a sequence to trim zeros along multiple axes.
New C API function registers multiple ufunc loops from specs in one call, including sorting and argsorting loops using ArrayMethod.
New x86 CPU feature group representing x86-64-v2 microarchitectures.
NumPy passes
copywhen it is non-default; implementations of the array protocol should accept it with the same meaning as in array constructors.f2py supports annotating functions and subroutines with
bind(c), handling type mapping and preserving unique labels for other C interfaces.A new public C API is available for creating custom dtypes.
The NEP 42 DType API is public, allowing custom DTypes outside NumPy through the normal
import_array()mechanism.Compile mode accepts the Meson backend; it is the default for Python 3.12 and newer.
Compile mode accepts one or more
--depflags, mapping todependency()calls in the Meson backend and doing nothing in the distutils backend.Support for updated Accelerate BLAS/LAPACK, including ILP64, adds arm64 support and performance improvements; it is selected at build time or automatically when no BLAS library is specified and available.
Added an ndarray attribute for Array API standard compatibility.
Added matrix-transpose support for ndarrays and MaskedArrays, equivalent to swapping the last two axes.
Added an ndarray method for Array API standard compatibility.
The new character codes were introduced for the corresponding integer types.
A find ufunc for unicode or byte strings, operating similarly to
str.findand used innp.char.An rfind ufunc for unicode or byte strings, operating similarly to
str.rfindand used innp.char.This functionality is available only after including
numpy/ndarrayobject.h, because it requiresimport_array().Added to the C API and Cython bindings to facilitate datetime conversions in external libraries.
New CLI script reports the NumPy version and compile flags for using the NumPy C API; --pkgconfigdir locates the pkg-config file.
Added as an alias to improve compatibility with the Array API standard.
Added as an alias to improve compatibility with the Array API standard.
Added a keyword-only device argument; only device="cpu" is supported.
Added a keyword-only device argument; only device="cpu" is supported.
Added an Array API standard-compatible alternative to the numpy.ndarray.astype method.
Counts the number of 1-bits in NumPy integer types and integer-like objects.
Added as an alias to improve compatibility with the Array API standard.
Introduced as the canonical name for NumPy's boolean dtype; numpy.bool_ is now an alias to it.
Added as an alias to improve compatibility with the Array API standard.
A new variable-length string dtype is available.
A C API is available for working with StringDType arrays, including locking string data and packing or unpacking UTF-8 bytestreams.
Added a keyword-only device argument; only device="cpu" is supported.
Added a keyword-only device argument; only device="cpu" is supported.
Added a keyword-only device argument; only device="cpu" is supported.
All FFT routines gained an out argument for in-place calculations.
Added a keyword-only device argument; only device="cpu" is supported.
Added a keyword-only device argument; only device="cpu" is supported.
A new introspection function accompanies canonical dtype names.
A tracing and introspection API reports available hardware-specific kernels and which will be dispatched to.
Added the upper keyword to improve Array API standard compatibility.
Added an Array API-compatible cross product function that accepts three-dimensional vectors only.
Added an Array API standard-compatible variant of numpy.diagonal, with different default axis selection for defining 2-D sub-arrays.
Added an Array API-compatible function that computes the matrix norm of a matrix or stack of matrices.
Added rtol to improve Array API standard compatibility.
Added as an alias for numpy.matrix_transpose.
Added an Array API-compatible outer product function that accepts one-dimensional arrays only.
Added rtol; if neither rcond nor rtol is specified, the rcond default is used. The notes say rcond is planned for future deprecation and removal.
Computes singular values for a matrix or stack of matrices and is compatible with the Array API standard.
Added as an alias to improve compatibility with the Array API standard.
Added an Array API standard-compatible variant of numpy.trace, with different default axis selection for defining 2-D sub-arrays.
Added as an alias for numpy.vecdot.
Added an Array API-compatible function that computes the vector norm of a vector or batch of vectors.
Added a keyword-only device argument; only device="cpu" is supported.
Added a function to calculate the matrix transpose of an array or stack of arrays by swapping the last two axes.
Added a keyword-only device argument; only device="cpu" is supported.
Added a keyword-only device argument; only device="cpu" is supported.
A pkg-config file is now included to help build systems use NumPy as a dependency.
A
weightskeyword is available; onlymethod="inverted_cdf"supports weights.Added stable to improve Array API standard compatibility.
Added correction as an Array API standard-compatible alternative to ddof; only one of the two arguments can be provided at a time.
A new namespace provides performant ufuncs for string operations.
With
strict=True, scalar broadcasting is disabled and input arrays must have the same data type.With
strict=True, scalar broadcasting is disabled and input arrays must have the same data type.Added as a NumPy integer mapping to C's unsigned long.
Added an Array API-compatible variant of numpy.unique with a fixed set of returned arrays, making it easier to target for JIT compilation.
Added an Array API-compatible variant of numpy.unique with a fixed set of returned arrays, making it easier to target for JIT compilation.
Added an Array API-compatible variant of numpy.unique with a fixed set of returned arrays, making it easier to target for JIT compilation.
Added correction as an Array API standard-compatible alternative to ddof; only one of the two arguments can be provided at a time.
Added a keyword to pass a precalculated mean, avoiding calculating the mean twice when it is also needed.
Added a function that computes the vector dot product of two arrays.
Added a keyword-only device argument; only device="cpu" is supported.
Added a keyword-only device argument; only device="cpu" is supported.
The main namespace now supports the array API standard.
A new, easier-to-use initialization function is available for the NumPy C API.
Sets an individual memory address like setting an array item, without requiring a NumPy array input.
A new, easier-to-use initialization function is available for the ufunc C API.
Added a variable-width UTF-8 string dtype with support for a user-provided missing-data sentinel, intended as a replacement for object-dtype Python string arrays.
Performance 8
Searching for multiple keys is substantially faster through batched binary search steps; single-key performance remains comparable.
Reductions over all axes now use a fast path for contiguous, aligned, non-object arrays with no special arguments.
Ufuncs scale significantly better on free-threading CPython builds through lock-free dispatch, immortal shared objects, and optimized memory allocation.
Iteration over large iteration spaces is significantly faster while preserving the original behavior and interface.
Single-input ufunc calculations on scalars are about six times faster; array performance is unchanged.
Quicksort uses Google's Highway VQSort on AArch64, improving execution time by up to 16x in some cases.
Fixed-length string operations have been accelerated with ufuncs that also support StringDType.
Sorting functions have been accelerated using Intel x86-simd-sort and Google Highway, with possible hardware-specific speedups.
Behavior and default changes 29
NumPy now uses PyMem_RawMalloc and PyMem_RawFree instead of the system malloc and free; internal allocations can be tracked by tracemalloc.
When dtype or order correction is needed, f2py now keeps a separate corrected array and copies it back after the Fortran call; only equivalent dtype kinds are allowed.
FFT functions now support non-float64 and non-complex128 dtypes and gain preliminary shape-typing support.
Input and output dtypes are more precise, and several functions gain preliminary, backward-compatible shape-typing support.
ndarray and its subclasses now support structural pattern matching with match/case statements.
The function now returns the full dtype descriptor, including parameters, for scalars of user-defined parametric data types.
This C API can now register real and imag ArrayMethods for use by imag and real.
Subclasses with dtype-specific logic should set _set_dtype to None to have arr.view(dtype=new_dtype) call __array_finalize__ with the new dtype, or define a function calling ndarray._set_dtype().
NumPy now supports the stable ABI for free-threaded Python.
Typing now accepts NumPy scalars and arrays as the second argument.
Accepts datetime strings.
The default parameter can accept array-like values.
The array interface accepts NULL data pointers and performs a dummy allocation; omit the data field to use the previous scalar path.
Assertion failure messages now include the indices at which the comparison fails.
The repr of NaT values now includes the datetime64 time unit.
Masked arrays accept and preserve Python strings as fill_value with variable-width StringDType, including through slicing and views; the default is N/A.
Hash-based unique extraction now supports complex dtypes and can return unsorted results.
Now natively supports type mappings defined by the Fortran2003 iso_c_binding intrinsic module.
The maximum number of array dimensions increases from 32 to 64.
Extended to work with unicode and bytes dtypes.
atol and rtol now accept scalars or arrays; arrays must broadcast to the shapes of the first two array arguments.
Now supports strings.
Now an alias to numpy.bool, the canonical name for NumPy's boolean dtype.
Now issues a UserWarning rather than a DeprecationWarning when the datetime string includes a timezone.
All FFT functions now support float32 and longdouble.
atol and rtol now accept scalars or arrays; arrays must broadcast to the shapes of the first two array arguments.
The shape argument now accepts any integer sequence, such as a list or NumPy array, as well as a tuple or int.
Its representation now includes the domain, making plain text and latex representations consistent.
Saving arrays with object dtype now uses pickle protocol 4, allowing objects larger than 4GB and improving speed for large arrays.
Tooling 4
The module now has typing annotations across masked arrays, masks, functions, and methods.
Many functions and methods now have shape-aware return annotations, allowing type-checkers to infer result array dimensions for common operations.
On win-arm64, the library file extension is now .lib instead of .a for MSVC and setuptools compatibility.
On win-arm64, the npymath and npyrandom static libraries now use the .lib extension instead of .a for compatibility with MSVC and setuptools.
Fixes and other changes 88
The item type in the dtype.descr typing is corrected.
MT19937 no longer accepts invalid buffers.
A hang when taking from a zero-size axis is fixed.
Bytes and Unicode counting mixups are fixed.
A crash when using an existing StringDType dtype is fixed.
The dtype is corrected when the first slice contains only NaNs.
Incorrect behavior with strided input and output is fixed.
Complex square-root rescaling is corrected.
Philox no longer accepts invalid buffers.
The number-of-elements calculation is corrected.
SeedSequence.spawn is made thread safe.
Bytes and code-point confusion in string fast search is fixed.
Bounds checking is performed before writing values when converting StringDType values to integers.
Calling ufunc.at with no inputs no longer segfaults.
Calling ufunc.at with a non-writeable first operand now raises an error.
Includes a workaround for an MSVC 19.51 bug.
Fixes truncation of the old and new strings to the length of the input array’s string.
Handles non-finite inputs more consistently.
Instances with equivalent floating-point NaN sentinels now have equal hashes, so dictionary lookups and set deduplication no longer fail because equal dtypes had different hashes.
Includes many typing fixes and improvements.
Fixes two possible crashes in the accumulate implementation.
When a dtype-changing ufunc leaves the copied fill_value invalid for the new dtype, NumPy now uses that dtype’s default fill_value instead of propagating a stale value.
Fixes the stride after removing a multi-index.
Fixes cast errors being swallowed during assignment.
Restores conjugate behavior for legacy user-defined dtypes.
Fixes a reference-count leak for overlapping copies when where is False.
Fixes corruption when reusing a StringDType.
Adds a special case for StringDType.
The release supports Python 3.15 and includes wheels for Python 3.15.0rc1.
Ensures the lock is held when accessing or writing RNG state and fully resets cached state for non-MT19937 RNGs.
Fixes the coerce flag in binary ufunc promotion.
Fixed an output-array leak in accumulate when dtype …
Corrected dtype inference for asarray([]).
The datetime Cython APIs were fixed to be compatible with older NumPy versions, helping downstream projects support those versions.
finfo is more accessible for user-defined dtypes.
Corrected the return type for object_ values.
Fixed a segfault by preventing recursive seed lists.
Fixed a typing regression introduced in NumPy 2.5.0.
Deadlocks when using the NpyString API were fixed.
Fixed an output-array leak in reduceat when dtype …
Fixed a leak in reductions when a ufunc override errors or is …
Fixed several bugs in StringDType operations.
Allocatable module variables wrapped by f2py now appear in dir() output.
numpy.triu_indices now accepts unsigned integers in all cases.
StringDType comparisons now correctly handle embedded NULL bytes.
Fixes a regression in arr.conj().
Fixes non-unitary results from np.linalg.svd(..., hermitian=True).
Fixes support for runtime type checkers.
Maps complex_long_double to NPY_CLONGDOUBLE.
Fixes typing for boolean and non-1D inputs.
Fixes in-place aliasing when out is the input.
Fixes a segfault when __getitem__ raises.
Undo the deprecation of the signature used by old pickles.
Fixes failures with a 0-dimensional out argument.
Fixes the assignability of np.shape for Python lists.
Fixes a memory leak when the fill-zero loop raises.
Prevents a deadlock caused by downstream code importing NumPy during dlopen.
Fixes typing for the axis parameter.
Fixes incorrect temporary elision for new-style user-defined dtypes.
Fixes 64-bit selection by using NPY_SIZEOF_UINTP.
Avoids a warning when a ufunc is called with where=True and no output.
Fixes handling of a bool array weekmask.
Fixes a weak hash function used by np.isin().
Fixes infinite recursion in np.ma.flatten_structured_array.
Adds missing extended precision imports to matlib's typing support.
Fixes the OpenBLAS threading problem on ARM.
Fixes memory leaks discovered after the 2.4.1 release.
Updates OpenBLAS to fix hangs.
Fixes the quantile promotion fixup.
Fixes validation of contraction axes.
Fixes a leak in the flat assignment iterator.
Fixes the return type of histogram2d.
Preserves the SeedlessSequence typo so wheels using the random Cython API and built against NumPy < 2.4.0 run without errors.
Many NumPy functions, classes, and methods now return meaningful signatures instead of raising ValueError, improving introspection and tooling support.
Accuracy is improved for 16- and 32-bit floating-point input data.
This release supports Python versions 3.11–3.14.
Fixed resize when the array contains references.
Fixed the implementation to avoid negating INT_MIN.
Fixed float16-sort failures on 32-bit x86 MSVC.
Fixed an assertion failure in buffer setup.
A malloc failure now emits MemoryError.
Fixed umath strides for AIX compatibility.
INT_MIN % -1 now returns 0 for all signed integer types.
Fixed negative samples generated by the Wald distribution.
Now handles common blocks with kind specifications from modules.
Python C-API functions can now be used correctly when parsing arguments typed as npy_intp.
The third argument now has str called on it automatically, matching the built-in assert statement's message behavior.
C code can still create intptr_t or uintptr_t typed arrays in a cross-platform way using the
ptype code.