Python 3.9 is officially released, lets check the new features!

Sajjad Hussain
Oct 13 · 3 min read
Image for post
Image for post

This month, Python 3.9.0 was finally released, which can be said to be “coming out after a thousand calls”! Compared with 3.8, what new features does Python 3.9 have?

Note that Python 3.9.0 cannot be used on Windows 7 or earlier.

New grammatical features

PEP 584, adding a merge operator to dict

In PEP 585, the types in the standard multiple sets are labeled generics.

PEP 614, relax the grammatical restrictions on decorators.

New built-in features

PEP 616, string method for removing prefix and suffix.

New features in the standard library

PEP 593, flexible function and variable labeling;

Added os.pidfd_open() to allow process management without competition and signals.

Improvement of interpreter

PEP 573, from the C extension type method to quickly access the module status;

PEP 617, CPython now uses a new PEG-based parser;

Many built-in Python types (range, tuple, set, frozenset, list, dict) are now accelerated by using PEP 590 vectorcall;

Garbage collection will not be blocked by the restored object;

Many Python modules ( _abc, audioop, _bz2, _codecs, _contextvars, _crypt, _functools, _json, _locale, math, operator, resource, time, _weakref ) now use the multi-stage initialization defined by PEP 489;

Many standard library modules ( audioop, ast, grp, _hashlib, pwd, _posixsubprocess, random, select, struct, termios, zlib ) now use the stable ABI defined by PEP 384.

New library module

PEP 615, the IANA time zone database is now included in the zoneinfo module of the standard library ;

The implementation of graph topological sorting is now provided by the new graphlib module.

New features

In this update, in addition to the above, there are some more important new features worthy of attention-

1. Dictionary merge and update operators

The merge ( | ) and update ( |= ) operators have been added to the built-in dict class. They provide a supplement to the existing dict.update and {**d1, **d2} dictionary merge methods.

2. Added string method for removing prefix and suffix

Added str.removeprefix (prefix) and str.removesuffix (suffix) to easily remove unnecessary prefixes or suffixes from strings. Corresponding methods of bytes, byte array and collections.UserString have also been added .

3. Type annotation generics in standard multiple sets

In the type annotation, you can now use the built-in polynomial types such as list and dict as common types without importing the corresponding capitalized type names (such as List and Dict ) from typing . Some other types in the standard library are now also common, such as queue.Queue .

Modification of other language features

__import__() now raises ImportError instead of ValueError , which used to happen when relative import exceeds its highest level package.

New module

1. zoneinfo

The zoneinfo module introduces the IANA time zone database to the standard library. It adds zoneinfo.ZoneInfo , which is an entity datetime.tzinfo implementation based on system time zone data .

2. graphlib

A new graphlib module has been added, which contains the graphlib.TopologicalSorter class to provide graph topological sorting functions.

Improved module

Adding the new cancel_futures parameter to concurrent.futures.Executor.shutdown() can cancel all pending Futures that have not yet started running, without having to wait for them to finish running and then shut down the executor.

In addition, there is more detailed content in the official Python documentation. I only list the important items here, and interested students can go to the official website to view the completed version. At the same time, the first Alpha version of Python 3.10.0 has been released, and the next version, 3.10.0a2, is expected to be released on November 2.

Cloud Belivers

Everything you need for your next application task

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store