What’s New in Python 3.13
Python continues to improve itself by focusing on performance and enhancing the developer experience. All these new features will make Python more robust and efficient. We can continue to expect additional performance improvements in the future releases.
A Better Interactive Interpreter
This update adds many new features to the REPL. The interactive shell now supports colorized prompts, multiline editing with history preservation, interactive help, history browsing, paste mode, and a set of REPL-specific commands (e.g., help
, exit
).
Improved Performance
Finally, Python 3.13 has added experimental support for disabling the GIL (Global Interpreter Lock). This has been the main factor behind Python’s poor performance for quite some time. However, this is just the first step. Some performance improvement is to be expected, but it will probably still take a few updates to witness a significant performance boost. To use this feature, Python will utilize an experimental free-threaded build mode, allowing more threads to run concurrently without being limited by the GIL. This could be beneficial for many CPU-bound tasks, such as scientific computing, data analysis, and other workloads.
An experimental JIT (Just In Time) compiler has also been added. In its current state, this will not have a huge effect on performance. The JIT works by taking a specialized Tier 1 bytecode and translating it to a new intermediate representation Tier 2 optimized for translation to machine code. As with the GIL, it is expected to improve Python’s performance further down the line. It should already have some positive effects on code sections that rely directly on machine code execution.
The cyclic garbage collector is now incremental. In programs with many objects, this should create smaller pauses for collection. This should help Python run more smoothly.
Again, most of these features are in an experimental state and will not have a strong impact on Python’s performance as is. However, this is clearly a first step in the right direction.
Improved Error Messages
We have seen improvements in error handling for the last three updates. This version follows that trend.
Python 3.13 improves some error messages to make them more explicit by suggesting the correct keyword argument to pass to a function, or by providing more details in case of a name collision with the standard library. It also adds colors to the tracebacks.
Improved Typing
You can now add defaults to any type parameters. You can use TypeVar()
with the default
parameter to specify a default type parameter when no type is specified.
A new type narrowing annotation has been added. typing.TypeIs
is different from typing.TypeGuard
as it can narrow the type in both the if
and else
branches of a conditional.
Finally, a read-only items type annotation has been added in TypeGuard
.
Numerous Improved Modules
Following what was started in the last update, a few modules have been removed from the standard library. Some other deprecations have also been planned for Python 3.15 and 3.16.
textwrap.indent()
is now 30% faster for larger input sizes. This improves the efficiency of text manipulation operations. Some modules have also seen improvements in import times by reducing the number of dependencies, such as the time
module.