View : 104

02/12/2026 10:00am

A ginger cat curled up asleep on a closed laptop on a wooden desk in afternoon light with books and a coffee mug blurred behind, with the text What's new in Python 3.15, lazy import and frozendict, and a card showing the 9 October 2026 release date

What's New in Python 3.15: Lazy Imports, frozendict, the Tachyon Profiler and UTF-8 by Default

#Python 3.15

#lazy import

#frozendict

#Tachyon profiler

#Python

Imagine your Python script takes several seconds to start even when you only type --help. A common cause is that modules imported at the top of the file are all loaded even though none has been used yet.

Python 3.15 was released on 9 October 2026 and has an answer for that. Today Superdev Academy walks through the headline features from What's new in Python 3.15, with code examples taken from the documentation and the cautions to keep in mind when you upgrade.

Lazy imports: load a module when you use it

PEP 810 adds a lazy keyword that postpones loading a module until the name is first used. An example from the documentation:

lazy import jsonlazy from pathlib import Path

print("Starting up...")  # json and pathlib are not fully imported yet

data = json.loads('{"key": "value"}')  # json is imported herep = Path(".")  # pathlib is imported here

The documentation states a limit: lazy works only at module level. Writing it inside a function, a class or a try block raises a SyntaxError. There is also an option to turn it on for the whole program through -X lazy_imports or the PYTHON_LAZY_IMPORTS environment variable.

One thing to think about: if a deferred module has code that runs at import time, such as registering a plugin, the moment that code runs will change. We infer this from how lazy imports work and did not read it directly in the documentation, so test a project that has such modules before enabling it program-wide.

frozendict: a dict that cannot change and can be hashed

PEP 814 adds frozendict as a built-in: an immutable mapping that keeps insertion order but compares equal regardless of order. An example from the documentation:

>>> a = frozendict(x=1, y=2)>>> a['z'] = 3TypeError: 'frozendict' object does not support item assignment>>> b = frozendict(y=2, x=1)>>> hash(a) == hash(b)True>>> a == bTrue

The direct benefit is as a constant, config-style value that nobody can modify while the program runs, or as a key in another dict because it is hashable.

Tachyon: a profiler you attach to a running process

Tachyon is a sampling profiler in the new profiling package (PEP 799), located at profiling.sampling. The documentation says it has low overhead, can attach to a running process without code changes, and can sample at up to 1,000,000 Hz. It has wall-clock mode (the default), CPU, GIL-holding and exception-time modes, and can output several formats such as --flamegraph and --heatmap, plus --live and --async-aware modes for asyncio.

One point to remember: the old profile module is deprecated and will be removed in Python 3.17. If you have older scripts that call it, start migrating now.

UTF-8 is the default for reading and writing files

PEP 686 makes reads and writes that do not specify an encoding always use UTF-8, whatever the system locale. That should help people who work with Thai on Windows, because it reduces files that come out garbled when read (this is our own observation).

open('flying-circus.txt')  # now uses UTF-8

If you want the old behaviour, set PYTHONUTF8=0 or use -X utf8=0, but the documentation recommends that code which must be portable across systems always pass encoding explicitly.

sentinel and what was removed

PEP 661 adds sentinel as a built-in type for creating unique special values, with a short representation, identity preserved on copy, and support for the | operator in type expressions. On the removal side, CGIHTTPRequestHandler and the --cgi flag of http.server were reported removed after being deprecated since 3.13. The full list of removals is in the removals section of the documentation. We did not read every module, so we suggest opening it before you upgrade.


Summary: start by trying lazy imports and the profiler

Python 3.15 was released on 9 October 2026 with lazy imports, frozendict, Tachyon, sentinel and UTF-8 as the default. Start by adding lazy to a script that starts slowly and measure before and after with Tachyon. For a real project upgrade, test encoding behaviour and read the removals section of the documentation in full first.

If you would like to start learning to code from the fundamentals, look at the courses from Superdev Academy at learn.superdevacademy.com/courses. There are currently the Go Cheat Sheet and Git & GitHub Essentials courses, and neither covers Python 3.15.

🎯 Follow dev knowledge from Superdev Academy:

FAQ: Frequently Asked Questions about This Article

A collection of questions and answers to help you better understand the content of this article.