NumPy 1.20 introduces type annotations

Major upgrade to the scientific package for Python also features expanded use of SIMD, increasing the execution speed of universal functions.

NumPy 1.20.0, described as the largest-ever release of the scientific computing package for Python, has arrived, introducing new capabilities such as type annotations and expanded use of SIMD (single instruction, multiple data).

Release notes for NumPy 1.20.0 indicate type annotations have been added for large parts of NumPy. There also is a new numpy.typing module containing useful types for end users. Currently available types include ArrayLike, for objects that can be coerced into an array, and DtypeLike, for objects that can be coerced into a dtype.

Wider use of SIMD in NumPy increases execution speed of universal functions (ufuncs). Work was done to introduce universal functions that will ease the use of modern features on different hardware platforms. In addition, improvements have been made to pave the way to NEP-38 (NumPy Enhancement Proposal) SIMD performance optimizations.

Other additions and improvements in NumPy 1.20.0 include:

  • Preliminary work on changing the dtype (data type object) and casting implementations to provide for extending dtypes.
  • Preliminary support for version 3.0 of the Cython language for writing C extensions for Python.
  • The randon.Generator class has a new permuted function.
  • Indexing errors shall be reported even when the index result is empty.
  • A where keyword argument has been added, to only consider specified elements or subaxes from an array in the Boolean evaluation of all and any.
  • Types in numpy.typing now can be imported at runtime.
  • The sliding_window_view function offers a sliding window view for NumPy arrays.
  • When creating or assigning to arrays, in all revelant cases NumPy scalars now will be cast identically to NumPy arrays
  • Use of aliases of built-in types such as has been deprecated.
  • Inexact matches for mode and searchside have been deprecated.
  • Cleanups have been made pertaining to removing Python 2.7, with code readability improved and technical debt removed.

Installation instructions for NumPy can be found at Language versions supported by NumPy 1.20.0 include Python 3.7 through Python 3.9; support has been dropped for Python 3.6.

Copyright © 2021 IDG Communications, Inc.

How to choose a low-code development platform