Python 3.9 is released today with a massive list of changes, new features, and more.
This release brings the latest version with support until May 2022 while the current Python 3.8 will be out of support on April 2021.
So, you can start planning to upgrade your codebase, environments for Python 3.9.
Python 3.9 Features
The list is huge. So, here is a gist of the changes you can quickly take a look at.
Python 3.9 uses a new parser, based on grammar-based PEG instead of top-down parser LL(1). The new parser’s performance is roughly comparable to that of the old parser, but the PEG formalism is more flexible than LL(1) when it comes to designing new language features.
The ast module uses the new parser and produces the same AST as the old parser.
In Python 3.10, the old parser will be deleted and so will all functionality that depends on it.
In Python 3.9 only, you can switch back to the LL(1) parser using a command-line switch (-X oldparser) or an environment variable (PYTHONOLDPARSER=1).
Three new syntax features have been added. Python 3.9 adds a union operator to dict method which makes it easier to perform the various implementation. The other two features are type hinting generics in standard collections and relaxed grammar restrictions on decorators.
A new string method is introduced. This version now allows us to remove suffixes and prefixes from strings. No need to strip string by their length. The prefix and suffix is any string that is passed as an argument.
Two new library modules introduced in Python 3.9. IANA Time Zone Database module zoneinfo is added to the standard library. An implementation of a topological sort of a graph is now provided in the new graphlib module.
A huge performance boost is added to the Python interpreter via various improvements. For example, CPython now uses a new parser based on PEG. range, tuple, dict, etc are now faster due to PEP 590 vectorcall.
You can read the complete changes here.
Python 3.9 Download
The Windows and other executables are present in the below link as self MSI installer.
Ubuntu and Other Linux
Ubuntu 20.04 LTS provides the Python 3.8.x version at the moment. I am not sure which Python version would be in Ubuntu 20.10 (I will update later once I find out).
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.9
Fedora 33 will have Python 3.9 as default which is due release this month.
I would not recommend to install and make it a default parser in your current Linux distribution manually unless it is provided by distro. Because lots of system applications might not work properly due to version conflict.
So, wait until your distro provides the Python 3.9 via respective update channel.