1. YouTube Summaries
  2. Python 3.14: New Features and Performance Boosts

Python 3.14: New Features and Performance Boosts

By scribe 7 minute read

Create articles from any YouTube video or use our API to get YouTube transcriptions

Start for free
or, create a free article to see how easy it is.

Python 3.14: What's New and Improved

Python 3.14 is set to release in October 2025, bringing with it a host of new features, syntax improvements, and performance enhancements. This article will dive deep into the changes coming in this latest version of the popular programming language.

Release Schedule

The release schedule for Python 3.14 is as follows:

  • First beta: Beginning of May 2025
  • Three more beta releases
  • Two release candidates
  • Final release: October 2025

After the first beta, no new features will be added - only bug fixes and minor changes will be implemented.

Syntax Improvements

PEP 765: Disallowing return, break, and continue in finally blocks

One of the significant syntax changes in Python 3.14 is the implementation of PEP 765, which aims to prevent confusing and potentially error-prone code involving return, break, and continue statements within finally blocks.

Consider the following examples:

def example1():
    try:
        return 1
    finally:
        return 2

print(example1())  # Output: 2

In this case, the function will always return 2, regardless of what happens in the try block. This behavior can be counterintuitive and lead to bugs.

def example2():
    try:
        raise Exception("Error")
    finally:
        return 2

print(example2())  # Output: 2

Here, the exception is silently swallowed, and the function returns 2. This can make debugging difficult and hide important errors.

def example3():
    for i in range(5):
        try:
            return i
        finally:
            continue

print(example3())  # Infinite loop

This example creates an infinite loop, as the continue statement in the finally block prevents the function from ever returning.

To address these issues, Python 3.14 will emit a syntax warning for such cases. In future versions, this will become a syntax error, preventing developers from writing code with these potentially confusing constructs.

PEP 648: Deferred Evaluation of Annotations

Another significant improvement in Python 3.14 is the implementation of PEP 648, which introduces deferred evaluation of annotations. This change makes working with type annotations more flexible and less error-prone.

Previously, code like this would raise an error:

class MyClass:
    def method(self) -> ReturnType:
        pass

class ReturnType:
    pass

The error occurred because Python evaluated annotations at the time it encountered them, requiring all types to be defined before use. As a workaround, developers often used strings in annotations:

class MyClass:
    def method(self) -> "ReturnType":
        pass

class ReturnType:
    pass

With Python 3.14, forward references are now supported without the need for string annotations:

class MyClass:
    def method(self) -> ReturnType:
        pass

class ReturnType:
    pass

Python will postpone the evaluation of annotations until they are used, allowing for more flexible and readable code. This change even permits the use of reference types that aren't defined anywhere in the code, without resulting in runtime errors.

PEP 765: Simplified Exception Handling Syntax

Python 3.14 introduces a small but convenient syntax change for exception handling. Previously, when listing multiple exception types in an except block, parentheses were required:

try:
    # Some code that might raise exceptions
except (TypeError, ValueError):
    # Handle the exceptions

Starting from Python 3.14, these parentheses are optional:

try:
    # Some code that might raise exceptions
except TypeError, ValueError:
    # Handle the exceptions

However, if you want to capture the exception instance using the as keyword, parentheses are still required:

try:
    # Some code that might raise exceptions
except (TypeError, ValueError) as e:
    # Handle the exceptions

This change simplifies exception handling syntax, making it more consistent with other aspects of Python's syntax.

Performance Improvements

Python 3.14 brings several performance enhancements, making the language faster and more efficient in various scenarios.

Tail Call Interpreter

One of the most significant performance improvements in Python 3.14 is the introduction of a new type of interpreter called the tail call interpreter. This change has made Python up to 13% faster in certain scenarios.

To understand how the tail call interpreter works, let's first review how the Python interpreter (specifically CPython) typically executes code:

  1. The source code is broken into tokens (small pieces of code, like words in a sentence).
  2. These tokens are used to build an Abstract Syntax Tree (AST), which represents the structure of the code.
  3. The AST is compiled into bytecode, a form suitable for execution.
  4. The bytecode is executed by the Python Virtual Machine (PVM).

The execution step is crucial for performance, and the tail call interpreter optimizes this process. Here's a simplified explanation of how it works:

In the current Python implementation, bytecode execution looks something like this:

def execute_bytecode(bytecode):
    while True:
        instruction = get_next_instruction(bytecode)
        opcode, args = instruction
        operation = OPERATIONS[opcode]
        operation(args)

The tail call interpreter changes this approach:

def execute_bytecode(bytecode):
    instruction = get_next_instruction(bytecode)
    opcode, args = instruction
    operation = OPERATIONS[opcode]
    operation(args, bytecode, instruction_pointer)

In this new approach, each operation function is responsible for calling the next operation. This allows for tail call optimization, which can be optimized by modern compilers to avoid creating new stack frames and potential stack overflow issues.

The result is faster execution without the overhead of a loop and function calls in the compiled code.

Other Performance Enhancements

  • JIT Optimizer: An experimental Just-In-Time (JIT) compiler is in development, showing promising results with an average 2% performance improvement in benchmarks.
  • No GIL: The Global Interpreter Lock (GIL) removal project, while still experimental, aims to improve performance in multi-threaded scenarios.
  • AsyncIO Boost: AsyncIO has received a 10% overall performance boost according to the pyperformance benchmark.
  • I/O Model Improvements: Opening and reading small files is now about 15% faster due to a reduced number of system calls. The default buffer size has been increased from 8KB to 128KB, potentially providing a 3-5x speedup, especially on Windows.
  • Compression Improvements: The default compression level for zlib has been lowered from 9 to 6, improving performance by around 70% at the cost of compression ratio. On Windows, zlib-ng is now used as the implementation, increasing performance by another 80%.
  • Other Optimizations: Base64 decoding is now 10x faster, importing is 6x faster, and UUID functions (UUID3, 4, 5, and 8) are 20-40% faster.

New Features and Changes

PEP 741: Python Configuration C API

Python 3.14 introduces two new functions to the Python C API: Py_Config_Get and Py_Config_Set. These functions make the configuration of Python more flexible, allowing for easier customization of Python's behavior at runtime.

PEP 762: Deprecating PGP Signatures

This PEP deprecates PGP signatures used to verify CPython artifacts in favor of Sigstore, a modern signing and verification system. This change aims to improve the security and ease of use when verifying Python distributions.

Minor Changes and Additions

  • The map() function now has a strict argument, similar to zip(), to prevent silently ignoring extra values.
  • The memoryview built-in type is now subscriptable and generic.
  • pathlib.Path has new methods: with_copy(), copy_into(), move(), and move_into().
  • The unittest module now produces colorful output by default.
  • The built-in HTTP server uses a dark theme if the user's browser requests it.
  • The json module can now be used as a tool to validate and print JSON, similar to the jq tool.
  • The zipfile module now emits a ResourceWarning if a zip file is not closed properly.
  • The default protocol for pickle has been updated from 4 to 5.
  • Fraction and Decimal numbers have a new construction method: from_number().
  • The Unicode database has been updated to version 16.0.0.
  • Support for UUID versions 6, 7, and 8 has been added to the uuid module.

Summary of Changes

As of April 9, 2025, the changes in Python 3.14 include:

  • 1,716 commits by 646 authors
  • 2,135 files changed
  • 176,000 insertions and 259,000 deletions
  • At least 400 bug fixes
  • 67 new functions, classes, and methods
  • 29 performance improvements
  • 30 deprecated features
  • 68 removals of previously deprecated features

Conclusion

Python 3.14 brings a wealth of improvements, from syntax enhancements that make code clearer and less error-prone to significant performance boosts across various areas of the language. The introduction of the tail call interpreter and the ongoing work on the JIT compiler and GIL removal show that Python continues to evolve and adapt to the needs of modern software development.

While some changes, like the new annotation behavior and exception handling syntax, may require minor adjustments to coding practices, they ultimately contribute to a more robust and efficient programming experience. The performance improvements, particularly in areas like I/O operations and compression, will be especially beneficial for data-intensive applications.

As Python continues to grow in popularity across various domains, from web development to data science and machine learning, these enhancements in version 3.14 ensure that the language remains competitive, efficient, and developer-friendly. Whether you're a seasoned Python developer or just starting with the language, the improvements in Python 3.14 offer something for everyone, promising a more powerful and enjoyable programming experience.

Article created from: https://youtu.be/hzys1_xmLPc?si=9nctiwXbLUHyVl87

Ready to automate your
LinkedIn, Twitter and blog posts with AI?

Start for free