The latest version of Python is now available. Python 3.8 introduces a number of new features, including assignment expressions, positional-only parameters, and a new parallel filesystem cache.
Assignment expressions is a new syntax (:=) that will assign values to variables that are part of a larger expression. Because the syntax resembles a walrus’ eyes and tusks, it is also being referred to as the “walrus operator.” Assignment expressions are useful in situations where match objects are needed twice, in while-loops that compute a value to test loop termination and then use that value elsewhere, and in list comprehensions where a value is needed in both a filtering condition and the expression body, the team explained.
Positional-only parameters (/) is a new function parameter syntax that indicates that certain function parameters need to be specified positionally and can’t be used as keyword arguments. This new syntax allows Python functions to fully emulate the behaviors of existing C functions. It also allows developers to change parameter names down the road without breaking the code.
A new parallel filesystem cache configures the implicit bytecode cache so that it uses a separate parallel filesystem tree instead of the default __pycache__ subdirectories.
And in Python 3.8, the language now uses the same ABI when in release and debug mode.
This release also introduces an = specifier to f-strings. This is useful for self-documentation and debugging, because it allows developers to display a whole expression.
Other features include Python runtime audit hooks (PEP 578), a new C API for configuring Python Initialization (PEP 587), a new “vectorcall” protocol for formalizing existing optimizations in place for various classes, and pickle protocol 5, which introduces support for out-of-band buffers.
Python 3.8 also introduces a new module: importlib.metadata, which provides support for reading metadata from third-party packages. It also made improvements on several existing modules, including AST, asyncio, functools, idlelib and IDLE, inspect, math, multiprocessing, os.path, statistics, typing, unittest, and more.
In addition, several features have been deprecated and several APIs and features have been removed.
A more in-depth breakdown of features and changes can be found in the release notes.