Python 3.14 is here!
Python 3.14 came out this week and has many new features and improvements. For the full details behind the release, the documentation is the best source. However, you will find a quick overview of the major changes here.
As with most Python releases, backwards compatibility is rarely broken. However, there has been a push to clean up the standard library, so be sure to check out what was removed and what has been deprecated. In general, most of the items in these lists are things the majority of Python users do not use anyway.
But enough with that. Let’s learn about the big changes!
Release Changes in 3.14
The biggest change to come to Python in a long time is the free-threaded build of Python. While free-threaded Python existed in 3.13, it was considered experimental at that time. Now in 3.14, free-threads are officially supported, but still optional.
Free-threaded Python is a build option in Python. You can turn it on if you want to when you build Python. There is still debate about turning free-threading on by default, but that has not been decided at the time of writing of this article.
Another new change in 3.14 is an experimental just-in-time (JIT) compiler for MacOS and Windows release binaries. Currently, the JIT compiler is NOT recommended in production. If you’d like you test it out, you can set PYTHON_JIT=1
as an environmental variable. When running with JIT enabled, you may see Python perform 10% slower or up to 20% faster, depending on workload.
Note that native debuggers and profilers (gdp and perf) are not able to unwind JIT frames, although Python’s own pdb and profile modules work fine with them. Free-threaded builds do not support the JIT compilter though.
The last item of note is that GPG (Pretty Good Privacy) signatures are not provided for Python 3.14 or newer versions. Instead, users must use Sigstore verification materials. Releases have been signed using Sigstore since Python 3.11.
Python Interpreter Improvements
There are a slew of new improvements to the Python interpreter in 3.14. Here is a quick listing along with links:
Let’s talk about the top three a little. Deferred evaluation of annotations refers to type annotations. In the past, the type annotations that are added to functions, classes, and modules were evaluated eagarly. That is no longer the case. Instead, the annotations are stored in special-purpose annotate functions and evaluated only when necessary with the exception of if from __future__ import annotations
is used at the top of the module.
the reason for this change it to improve performance and usability of type annotations in Python. You can use the new annotationlib
module to inspect deferred annotations. Here is an example from the documentation:
Another interesting change is the addition of multiple interpreters in the standard library. The complete formal definition of this new feature can be found in PEP 734. This feature has been available in Python for more than 20 years, but only throught the C-API. Starting in Python 3.14, you can now use the new concurrent.interpreters
module.
Why would you want to use multiple Python interpreters?
They support a more human-friendly concurrency model
They provide a true multi-core parallelism
These interpreters provide isolated “processes” that run in parallel with no sharing by default.
Another feature to highlightare the template string literals (t-strings). Full details can be found in PEP 750. Brett Cannon, a core developer of the Python language, posted a good introductory article about these new t-strings on his blog. A template string or t-string is a new mechanism for custom string processing. However, unlike an f-string, a t-string will return an object that represents the static and the interpolated parts of the string.
Here’s a quick example from the documentation:
You can use t-strings to sanitize SQL, improve logging, implement custom, lightweight DSLs, and more!
Standard Library Improvements
Python’s standard library has several significant improvements. Here are the ones highlighted by the Python documentation:
Syntax highlighting in the default interactive shell, and color output in several standard library CLIs
If you do much compression in Python, then you will be happy that Python has added Zstandard support in addition to the zip and tar archive support that has been there for many years.
Compressing a string using Zstandard can be accomplished with only a few lines of code:
Another neat addition to the Python standard library is asyncio introspection via a new command-line interface. You can now use the following command to introspect:
python -m asyncio ps PID
python -m asyncio pstree PID
The ps
sub-command will inspect the given process ID and siplay information about the current asyncio tasks. You will see a task table as output which contains a listing of all tasks, their names and coroutine stacks, and which tasks are awaiting them.
The pstree
sub-command will fetch the same information, but it will render them using a visual async call tree instead, which shows the coroutine relationships in a hierarcical format. Ths pstree
command is especiialy useful for debugging stuck or long-running async programs.
One other neat update to Python is that the default REPL shell now highlights Python syntax. You can change the color theme using an experimental API _colorize.set_theme() which can be called interactively or in the PYTHONSTARTUP
script. The REPL also supports impor tauto-completion, which means you can start typing the name of a module and then hit tab to get it to complete.
Wrapping Up
Python 3.14 looks to be an exciting release with many performance improvements. They have also laid down more framework to continue improving Python’s speed.
The latest version of Python has many other imrpovements to modules that aren’t listed here. To see all the nitty gritty details, check out the What’s New in Python 3.14 page in the documentation.
Drop a comment to let us know what you think of Python 3.14 and what you are excited to see in upcoming releases!