Python 3.14 Has Arrived With T-String Support
Python 3.14 is officially here, and brings a mix of changes to the core language, the interpreter's guts, and the standard library. These are major updates like template string literals, deferred evaluation of annotations, and even official support for subinterpreters in the standard library.
Python is getting template string literals, or t-strings. These use the familiar f-string syntax (just swap the 'f' for a 't' like this: t'Mister {name}'), but instead of immediately combining the static text and your interpolated values into a single str object, they return a Template object. It basically separates the static and variable parts of the string at runtime. This new object is incredibly useful for sanitizing user input, like making sure a string is safe for HTML or a database query.
The way type annotations (like the : str you put on a function argument) are handled has completely changed with deferred evaluation. Annotations are no longer evaluated right away. This means it's no longer necessary to wrap annotations in strings to avoid NameError for forward references.
What's most interesting to me is that the interpreter is getting even more helpful with improved error messages. If you make a common typo in a keyword, like typing "whille" instead of while, the interpreter will now give you a suggestion for the correct keyword. You'll also get specific error messages for confusing syntax, like an elif block following an else block. These small changes will be a lifesaver for debugging.
One of the biggest themes in Python 3.14 is a push for speed and better handling of modern, multi-core systems. For those of you doing heavy-duty, CPU-intensive work, the free-threaded build of Python, which was experimental in 3.13, is now officially supported. This means the performance penalty on single-threaded code in free-threaded mode is now down to about five to 10%, which is a significant improvement. The goal is to make full use of multi-core CPUs, so you can scale your applications without the limitations of the Global Interpreter Lock.
A feature that was previously only accessible through the C-API is now available in the standard library through the new concurrent.interpreters module. Think of it like getting the isolation of processes with the efficiency of threads. It lets new, human-friendly concurrency models like the actor model, which is a big win for making concurrent software easier to implement and maintain. There are still some minor limitations as this feature goes mainstream, like slower startup times for new interpreters, so don't expect it to be perfect yet.
The new compression package is here, and it brings a dedicated module for the Zstandard format, compression.zstd. Zstandard is known for being a widely adopted, highly efficient, and fast compression format. It uses a similar API to the existing lzma and bz2 modules, so it should be a breeze to drop in.
Debugging asynchronous code can be a headache, so Python 3.14 adds new command-line tools for asyncio introspection. You can now inspect running processes with python -m asyncio ps PID to get a flat list of tasks, or use pstree for a visual async call tree. This is super helpful for figuring out where your program is blocked and how your coroutines are chained together.
You can download Python from its website or GitHub
Source: Python
