Python 3.15 is now available: what breaks when upgrading and the two changes you should try first

Python 3.15.0 is the latest stable version of Python: it came out on October 9, 2026 and, before updating, there are two changes you should test. UTF-8 becomes the default encoding on all platforms and the new lazy import keyword changes when your modules are loaded. The version also brings a built-in frozendict, a sentinel type and a sampling profiler called Tachyon, and removes APIs from seventeen standard library modules.

What’s New in Python 3.15?

The version brings together 5,643 commits from 1,012 people. These are the changes that affect everyday code:

  • PEP 810, explicit lazy imports. A new soft keyword, lazy, delays loading a module until the first use of the name.
  • PEP 686, UTF-8 by default. All I/O without an encoding argument uses UTF-8, regardless of the system locale.
  • PEP 814, frozendict. A built-in, immutable, and hashable mapping.
  • PEP 661, sentinel. A built-in type for creating unique sentinel values.
  • PEP 798, unpacking in comprehensions. [*L for L in lists] now flattens lists.
  • PEP 799, a profiling package. Includes Tachyon, a new statistical sampling profiler.
  • Better error messages. Python recognizes methods from other languages: [1, 2, 3].push(4) suggests .append and 'hello'.toUpperCase() suggests .upper.

There are also internal improvements:

  • The experimental JIT received a major update.
  • Official 64-bit Windows binaries now use the tail-calling interpreter.
  • The macOS installer includes free-threading support by default.

How to Install Python 3.15?

On Windows, use the Python install manager:

py install 3.15

On macOS, download the installer from the release page. It works on macOS 10.15 and later.

For other platforms there are source code tarballs.

A note for macOS, current at the time of publishing this note: the release page warns that IDLE and other applications with tkinter may hang on macOS 27.0 when a menu opens a dialog. The cause is an operating system change and affects all current versions of Python. As of October 9, 2026 there was no solution; tracking is at cpython#158053.

If you use uv, Barry Warsaw published a text adventure that walks through the 3.15 highlights. Each puzzle is solved by writing actual 3.15 code:

uvx --python 3.15 whatsnewt

What Should You Test First When Updating Python?

Test the encoding change first, because it can corrupt data without raising an error. Then test lazy imports, because they’re the change you’ll really want to adopt.

Does Python 3.15 Use UTF-8 by Default?

Yes. All calls that read or write text without an encoding argument now use UTF-8, regardless of the system locale. For example:

open('data.txt')

PEP 686 is explicit about who is affected. Most Unix systems already use a UTF-8 locale, so the change mainly affects those working on Windows. If your code relied on the default locale encoding, you may see UnicodeError, mojibake, or silent data corruption. The change covers files, stdio, and pipes, so calls to subprocess with text=True are also affected.

The PEP itself proposes a three-step migration.

1. Find every place where your code depends on the default value. Enable the optional warning:

python -X warn_default_encoding your_app.py

or set the environment variable:

PYTHONWARNDEFAULTENCODING=1

Python will emit an EncodingWarning at each place where the default encoding is used.

2. Make each call explicit.

  • Use encoding="utf-8" if the data is UTF-8.
  • Use encoding="locale" if you really want the system encoding. It’s been supported since Python 3.10.
  • If you call locale.getpreferredencoding(), change it to "utf-8" or locale.getencoding().

3. Buy time if you need it. You can disable the new behavior with PYTHONUTF8=0 or -X utf8=0. Use it as a bridge, not as a solution.

How Do Lazy Imports Work in Python 3.15?

Put lazy in front of the import. The module is loaded the first time you use the name, not at startup:

lazy import json
lazy from pathlib import Path

print("Starting...")  # json and pathlib haven't been fully imported yet

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

The gain is in the startup time of applications that import many modules but only use some on each run: CLIs, test runners, and serverless functions. You keep all imports at the top of the file, without spreading imports inside functions to avoid the cost.

Before adopting it, keep four things in mind:

  • Errors change location. If a module imported with lazy doesn’t exist, the exception is raised on first use, not on import. The traceback shows both the line where the name was used and the original import line.
  • Where it’s allowed. lazy only works at module level. Inside a function, inside a class body, or inside a try/except/finally block is a SyntaxError. So are lazy from module import * and lazy from __future__ import ....
  • Turn it on globally. -X lazy_imports=all or PYTHON_LAZY_IMPORTS=all make all imports lazy without touching the code. normal, the default, only respects the keyword.
  • Backwards compatibility. If your code must also run on versions before 3.15, define __lazy_modules__. The normal import statements of the listed modules become lazy in 3.15 and stay normal on earlier versions:
__lazy_modules__ = ["json", "pathlib"]

import json     # lazy
import os       # stays eager

For finer control, sys.set_lazy_imports_filter() accepts a function. The documentation uses it to make only your application’s modules lazy and keep third-party dependencies eager:

import sys

def myapp_filter(importing, imported, fromlist):
    return imported.startswith("myapp.")
sys.set_lazy_imports_filter(myapp_filter)
sys.set_lazy_imports("all")

What Breaks When Updating to Python 3.15?

Most of what was removed are APIs marked as obsolete since 3.12 or 3.13. If your test suite runs with deprecation warnings enabled, you probably already saw them. These are the ones most likely to break real code:

Module What Changed
datetime strptime() raises ValueError if the format has %d but no year
http.server CGIHTTPRequestHandler and the --cgi option are removed
sre_compile, sre_constants, sre_parse Modules are removed
typing Keyword syntax NamedTuple("Point", x=int, y=int) and TypedDict("TD") without fields are no longer supported
typing no_type_check_decorator is removed
ast Node constructors raise TypeError if a required argument is missing or an unknown keyword is received
pathlib PurePath.is_reserved() is removed (use os.path.isreserved())
glob glob0() and glob1() are removed (use glob.glob() with root_dir)
zipimport zipimporter.load_module() is removed (use exec_module())
importlib.resources The package parameter of files() is removed
platform java_ver() is removed
types codeobject.co_lnotab is removed
wave getmark(), setmark(), and getmarkers() are removed

The migration section of the documentation also lists behavior changes that are not removals:

  • sqlite3: all parameters of sqlite3.connect() except database become keyword-only.
  • argparse: in add_argument('-f', '-foo'), dest is now 'foo' not 'f'. Pass dest explicitly to keep the previous behavior.
  • unittest: assertWarns() and assertWarnsRegex() no longer swallow warnings that don’t match. Your tests may start showing warnings that were previously hidden.
  • base64: urlsafe_b64decode() no longer requires padding. Pass padded=True if your code relied on it.

What Is frozendict and How Does It Differ From dict?

frozendict is a new built-in, immutable mapping: once created, it cannot be modified. It’s hashable as long as its keys and values are, so it can be a dict key or set element, and serves where you’d previously improvise a cache key.

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

The key detail is that frozendict is not a subclass of dict: it inherits directly from object. That’s why any isinstance(arg, dict) check rejects it. The documentation suggests two replacements:

  • isinstance(arg, (dict, frozendict))
  • isinstance(arg, collections.abc.Mapping), which also accepts types like MappingProxyType

frozendict preserves insertion order, but comparisons ignore it. The standard library already accepts it in copy, json, pickle, pprint, and other modules. json.loads also adds an array_hook parameter: if you pass frozendict as object_pairs_hook and tuple as array_hook, you get a fully immutable structure from JSON.

How to Use Tachyon, Python’s New Profiler?

Tachyon lives in profiling.sampling. It takes periodic snapshots of the call stack from outside the process, so the CPython team describes its overhead on the profiled process as practically zero. Its most interesting feature is that it can attach to an already-running process, making it usable in production.

python -m profiling.sampling run script.py
python -m profiling.sampling run --flamegraph -o profile.html script.py
python -m profiling.sampling attach 12345
python -m profiling.sampling dump 12345

  • dump prints a single snapshot in traceback format. It’s useful with a hung process.
  • --live opens a top-style view in the terminal.
  • --mode cpu measures only CPU time, and --mode gil measures GIL hold time.

Attaching to a process requires permissions:

  • Linux: root, the CAP_SYS_PTRACE capability, or a more permissive ptrace scope.
  • macOS: root or a debugger entitlement.
  • Windows: administrator privileges.

The profiler and process must use the same minor version, so you can’t attach from 3.14 to a process on 3.15.

The old cProfile remains as an alias. profile is obsolete and will be removed in 3.17.

What Else Changes: sentinel, Comprehensions, and the JIT?

  • sentinel is a new built-in type for creating unique marker values. They preserve their identity when copied, work in type expressions with |, and can be serialized with pickle if they can be imported by module and name.
  • Unpacking in comprehensions replaces nested comprehensions and itertools.chain(): [*L for L in lists] flattens a list of lists and {**d for d in dicts} merges dictionaries.
  • The JIT remains experimental. According to measurements from CPython’s own pyperformance, published on the release page, it improves the geometric mean between 7 and 8 percent over the standard interpreter on Linux x86-64, and between 11 and 12 percent on macOS AArch64 over the tail-calling interpreter. These are self-reported benchmarks, not a guarantee for your workload.
  • The garbage collector is generational again. Python 3.14.0 through 3.14.4 included an incremental collector. After reports of significant memory pressure in production, it was reverted starting in 3.14.5, and 3.15 keeps the generational one.

Python 3.15 or Python 3.14: Should You Upgrade Now?

It depends on what your code touches:

  • If you work mainly on Unix and already pass encoding explicitly: the upgrade should be low risk. The main gains are lazy imports for startup and Tachyon for profiling.
  • If you’re on Windows or read files without explicit encoding: run first with -X warn_default_encoding and fix each warning before switching.
  • If you depend on removed APIs: the table above tells you what to look for in your code.
  • If you maintain libraries or depend on many: wait for your critical dependencies to release wheels for 3.15, which is usually the bottleneck.

And you? What version of Python runs in your production today?

Are you going to migrate to Python 3.15 this quarter?
  • Yes, I’m already testing it
  • When my dependencies support it
  • Not this year
  • I prefer another option (tell us which)
0 votantes

Comment below or, if this article reached you by email, reply directly to the email: your reply is published here.