NumPy 2 Released |
Written by Kay Ewbank |
Tuesday, 25 June 2024 |
NumPy 2.0 has been released, the first major new version since 2006. NumPy is the fundamental mathematical library for Python, and this release adds new features and performance improvements, but also breaking changes. The NumPy library extends the features of Python to add support for large, multi-dimensional arrays and various derived objects such as masked arrays and matrices. These can then be analysed and worked with using NumPy's extensive range of high-level mathematical functions. NumPy has an assortment of routines for fast operations on arrays, including mathematical, logical, shape manipulation, sorting, selecting, I/O, discrete Fourier transforms, basic linear algebra, basic statistical operations, and random simulation. It has tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities. Announcing the new release, the developers said in a blog post: "NumPy has improved and evolved over the past 18 years, with many old releases bringing significant performance, usability, and consistency improvements. That said, our approach for a long time has been to make only incremental changes while carefully managing backward compatibility. This approach minimizes user breakage, but also limits the scope of improvements that can be made, both to the API and its underlying implementation." In view of this, the team decided to break backward compatibility to implement significant improvements in NumPy’s type system. The developers say that as the type system is fundamental to NumPy, major behavioral changes could not be made incrementally without mixing two different type systems, which would be a recipe for disaster. The improvements to the new release start with a reworking of the Python API to clean it up and streamline it. The developers say this should make it easier to learn and use NumPy. The main namespace has been reduced by approximately 10%, and the more niche numpy.lib namespace has been reduced by about 80%, providing a clearer distinction between public and private API elements. There are also improved scalar promotion rules, addressing "surprising behaviors" in type promotion, e.g. with zero dimensional arrays. A new DType API has been added along with a new string dtype. The new API can be used to implement user-defined custom data types, and the developers have used it to implement StringDType, offering what they say is efficient and painless support for variable length strings. They hope it will enable future new data types with interesting new capabilities in the PyData ecosystem and in NumPy itself. Windows compatibility enhancements have been made so the default 32-bit integer representation on Windows has been updated to 64-bit on 64-bit architectures, addressing one of the most common problems with having NumPy work portably across operating systems. There's also now support for the Python array API standard, and existing APIs and behavior have been aligned with the standard. NumPy 2 is available now. More InformationRelated ArticlesThe Best Numerical Library Comes to Python - NAG For Python Advanced Python Arrays - Introducing NumPy New number crunching library - NAG C Mark 9 To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info <ASIN:1871962595> |
Last Updated ( Tuesday, 25 June 2024 ) |