Python 3.9 and the exciting features it brings - Questers

Python 3.9 and the exciting features it brings

The release of the new Python 3.9 is coming up next week and is bringing some very cool features. It offers a faster release schedule, boosts in the performance and neat string functions. Let’s take a deeper look at some of the updates.

Performance improvements

Usually, every new release of Python comes with performance improvements. The 3.9 release is not an exception. It brings two enhancements that increase the performance without the need to change the existing code.
The first one is the use of vectorcall protocol by several built-ins (range, tuple, set, frozenset, list, dict) to speed up execution.
The other main performance improvement is the new parser based on PEG instead of LL(1). And although they have comparable performances, the PEG is more flexible in the design of new features. It is expected that the 3.10 and later versions will make use of this flexibility.

New type operations

The 3.9 release presents two new features for type hinting and type annotations. The first one enables the support for the generic syntax in all standard collections currently available in the typing module.
The second one is the Flexible function and variables annotations that allow the use of Annotated type to describe a type using metadata that can be examined ahead of time or at runtime.

More string and dictionary functions

The new release extends the opportunity to easily manipulate data types adding new features for strings and dictionaries. The methods removeprefix() and removesuffix() have been added to ease the removal of an unneeded prefix or suffix from a string. Additionally, merge and update operators have been added to the dict class to overcome the disadvantages of the current ways of merging and updating dictionaries.

Support for the IANA Time Zone Database in the Standard Library

This update of Python introduces the new module zoneinfo. It provides a concrete time zone implementation supporting the IANA time zone database. By default, zoneinfo shows the system’s time zone data. If it is not available, the library will fall back to the first -party package tzdata, deployed on PyPI.