What’s New In Python 3.13¶
- Editors:
Adam Turner and Thomas Wouters
This article explains the new features in Python 3.13, compared to 3.12. Python 3.13 was released on October 7, 2024. For full details, see the changelog.
See also
PEP 719 – Python 3.13 Release Schedule
Summary – Release Highlights¶
Python 3.13 is a stable release of the Python programming language, with a mix of changes to the language, the implementation and the standard library. The biggest changes include a new interactive interpreter, experimental support for running in a free-threaded mode (PEP 703), and a Just-In-Time compiler (PEP 744).
Error messages continue to improve, with tracebacks now highlighted in color
by default. The locals() builtin now has defined semantics for changing the returned mapping,
and type parameters now support default values.
The library changes contain removal of deprecated APIs and modules, as well as the usual improvements in user-friendliness and correctness. Several legacy standard library modules have now been removed following their deprecation in Python 3.11 (PEP 594).
This article doesn’t attempt to provide a complete specification of all new features, but instead gives a convenient overview. For full details refer to the documentation, such as the Library Reference and Language Reference. To understand the complete implementation and design rationale for a change, refer to the PEP for a particular new feature; but note that PEPs usually are not kept up-to-date once a feature has been fully implemented. See Porting to Python 3.13 for guidance on upgrading from earlier versions of Python.
Interpreter improvements:
A greatly improved interactive interpreter and improved error messages.
PEP 667: The
locals()builtin now has defined semantics when mutating the returned mapping. Python debuggers and similar tools may now more reliably update local variables in optimized scopes even during concurrent code execution.PEP 703: CPython 3.13 has experimental support for running with the global interpreter lock disabled. See Free-threaded CPython for more details.
PEP 744: A basic JIT compiler was added. It is currently disabled by default (though we may turn it on later). Performance improvements are modest – we expect to improve this over the next few releases.
Color support in the new interactive interpreter, as well as in tracebacks and doctest output. This can be disabled through the
PYTHON_COLORSandNO_COLORenvironment variables.
Python data model improvements:
__static_attributes__stores the names of attributes accessed throughself.Xin any function in a class body.__firstlineno__records the first line number of a class definition.
Significant improvements in the standard library:
Add a new
PythonFinalizationErrorexception, raised when an operation is blocked during finalization.The
argparsemodule now supports deprecating command-line options, positional arguments, and subcommands.The new functions
base64.z85encode()andbase64.z85decode()support encoding and decoding Z85 data.The
copymodule now has acopy.replace()function, with support for many builtin types and any class defining the__replace__()method.