Development

The best new features in Python 3.15

Python 3.15 is one of the most feature-packed Python releases in many a moon, and the first release candidate has just arrived. Here’s a rundown of the biggest, boldest, and most important innovations, changes, and fixes. A long-asked for feature, lazy imports allow imports to…

The best new features in Python 3.15

Python 3.15 is one of the most feature-packed Python releases in many a moon, and the first release candidate has just arrived. Here’s a rundown of the biggest, boldest, and most important innovations, changes, and fixes.

A long-asked for feature, lazy imports allow imports to be processed only when they’re actually used by the program. For slow-importing modules that impose a large cost on a program’s startup time, you can defer that cost to when the code of that module.

What Happened

You can use lazy imports explicitly using the new lazy import syntax, but you can also force code with conventional imports to behave lazily, either programmatically or by using an environment variable. This makes it easy to make existing code take advantage.

Advertisement
  • With Python 3.15, though, the JIT is now showing an 8% to 13% geometric mean performance improvement over standard CPython, depending on the platform and workload.

  • The incremental collector may return in a future version, but not without additional work done on it to keep this problem from resurfacing.

  • Unfortunately, many users reported the new garbage collector increases process memory usage, sometimes dramatically.

Key Details

Best of all, there’s no drawback to making imports lazy: they otherwise behave exactly as intended. Only rarely does Python add a new data type, but this is a long-debated and long-desired addition: the frozen dictionary.

  • Python 3.14 featured a major change to its garbage collection system—an incremental garbage collector intended to reduce the amount of program-stopping time needed to collect garbage.

  • With this, type annotations can be used in places where the type itself is being used as a value—for instance, variations on operations like typing.cast or even isinstance, or as part of how a.

  • The TypeForm type definition lets you represent the value that results from evaluating a type expression.

Why It Matters

The frozendict behaves like a regular dictionary, except that it’s immutable (you can’t add, remove, or change elements) and it’s hashable (so you can use it as a key in another dictionary, for instance). Another new addition to the language is intended.

  • The extra_items argument lets you specify additional keys at runtime, but only keys with a value of a specified type.

  • The closed argument lets you specify if only the keys specified can be used at runtime.

What Reports Say

Coverage of the story so far points to:

  • Continued reporting by InfoWorld as more details emerge

Advertisement
Development Best Features Python 2026 Updates

More in Development

View all →