NumPy 1.22 kicks off windows/arm64 support, completes main annotation work

NumPy 1.22 kicks off windows/arm64 support, completes main annotation work

After more than a half year of work, the NumPy team has released version 1.22 of the scientific computing library – the first to be able to work with windows/arm64 targets.

Amongst other things, the new version allows developers to compute the number of 1-bits in an integer through the new bit_count function, use comment blocks to generate C/C++ API reference documentation, and keep the dimensions of reduced axes when using argmin and argmax in combination with new keepdims argument.

The interpolation= keyword argument in quantile and percentile has been replaced by a new method= one, which is said to support 13 methods that align with scientific literature, the R language, and previously available approaches. NumPy’s floating point and integer types have been fitted with a float.is_integer implementation since the last release, and numpy.ndarray, numpy.dtype and numpy.number classes are now subscriptable for Python 3.9 or newer, which should make the use of certain expressions more straightforward.

The latest iteration also quenches some more particular needs, by providing things like an option to configure allocators for data segments of a ndarray, which has been included to help realise hardware-specific optimisations. The addition was spurred by teams running into performance degradations using the regular memory management strategy, though most regular users will probably keep accepting the bottleneck for the sake of simplicity.

Meanwhile, the plugin for static type checker mypy has been extended to be able to set the platform-specific c_intp precision which is for instance utilised as the data type for numpy.ndarray.cytypes attributes.

Developers who like to get in on new additions early, can take a look at the initial implementation of an enhancement proposal that seeks to support the Python array API standard. The still experimental feature allows users to make sure their code is portable and works with a variety of other multidimensional array libraries such as TensorFlow and PyTorch. There’s also a new header (experimental_public_dtype_api.h) available to facilitate investigations into the upcoming APIs for user DType support and universal functions. 

Apart from this, NumPy 1.22 marks the complete annotation of the main NumPy namespace, a process that started in the runup to the 1.20 release last year. Other sub-packages that have since been fitted with annotations include numpy.testing, and numpy.linalg.

In order to have NumPy 1.22 work properly, the library needs Python 3.8 or higher to be installed, as support for Python 3.7 was dropped with the release.

Before updating to the new version, developers should also be aware that passing boolean kth values to numpy.partition and numpy.argpartition isn’t an option anymore and that previously deprecated loads, ndfromtxt, and mafromtxt have been removed for good in v1.22. Other changes mean that the library will throw a TypeError should floor division of complex types be attempted, and produce the same output class as the base function when numpy.vectorize is used.