3.12.12

Latest release in branch 3.12
Released 1 month ago (October 09, 2025)

Software Python
Branch 3.12
Status
Supported
End of life October 02, 2028
First official release version 3.12.0
First official release date 2 years ago (October 02, 2023)
Documentation https://docs.python.org/release/3.12.12/
Download https://www.python.org/downloads/release/python-31212/

Python 3.12 Release Notes

Python 3.12.0, released on October 2, 2023, brings significant improvements in performance, error messages, and developer tools. This version introduces faster CPython with a new specializing adaptive interpreter, better f-string debugging, type parameter syntax in generics, and enhanced support for Linux perf profiling. It also removes several deprecated features and modules as part of ongoing modernization efforts.

With over 200 performance optimizations, Python 3.12 runs about 5% faster on average than 3.11, especially in function calls, list operations, and method lookups. It maintains full backward compatibility for most code while setting the stage for future concurrency improvements like free-threaded execution.

Specializing Adaptive Interpreter

The new interpreter dynamically specializes bytecode based on runtime types. It starts with generic instructions and replaces them with faster type-specific versions when patterns are detected -- for example, converting BINARY_ADD to BINARY_ADD_INT when both operands are integers.

This reduces overhead in hot loops and common operations. Specializations cover integers, floats, strings, lists, and method calls. The system is self-tuning and requires no code changes.

Improved f-string Debugging

f-strings now support = for self-documenting expressions. Write f"{expr=}" to include both the expression and its value in output, like expr=42.

This is especially useful in logging and debugging. Nested f-strings and reuse of the = specifier are fully supported, making complex expressions clearer without extra print statements.

Type Parameter Syntax

PEP 695 introduces a new, cleaner syntax for generics using def, class, and type statements. Define type variables directly in function or class scope:

def max[T](a: T, b: T) -> T: ...

This replaces the older from typing import TypeVar pattern, reducing boilerplate and improving readability in type-heavy code.

Linux perf Profiler Support

Python 3.12 adds built-in support for the Linux perf tool. Run python -X perf to generate profiling data that perf report can read, showing exact Python line numbers and function calls.

No source modifications needed. This enables deep performance analysis in production-like environments, identifying bottlenecks at the interpreter level.

Performance Improvements

Function calls are 3-10% faster due to inline caching and reduced frame overhead. List and dict literals build up to 25% quicker. Method calls benefit from per-type caches.

super() without arguments is faster in single inheritance. String concatenation in loops is optimized. Overall, the pyperformance suite shows a 5% average speedup.

Enhanced Error Messages

Error messages are more precise. For example, NameError now suggests "Did you mean: 'other_name'?" when a similar name exists in scope. Import errors show the full path of the failing module.

SyntaxError points to the exact token. Unclosed parentheses or brackets highlight the opening location. These changes help developers fix issues faster.

New Syntax Features

Beyond f-string debugging and type parameters, Python 3.12 allows except* for exception groups (PEP 654), enabling handling of multiple exceptions from concurrent tasks.

Variadic generics with *args: *Ts and **kwargs: **Ps are supported. The type statement defines type aliases cleanly: type Point = tuple[float, float].

Standard Library Updates

pathlib: Path.walk() for recursive traversal. statistics: fmean() supports weights. sqlite3: Faster row factory, iterdump() returns iterator.

os: cpu_count() includes only online CPUs by default. tkinter: Dark mode detection on macOS. zoneinfo: IANA database updated.

dataclasses: KW_ONLY for keyword-only fields. array: 'u' type code for Unicode removed (use str).

Deprecations

wsgiref, smtplib, distutils are deprecated in favor of modern alternatives. asynchat, asyncore, smtpd are removed.

Passing non-path objects to Path methods is deprecated. typing.AnyStr is deprecated. pkgutil.find_loader() and imp module are gone.

Removals

Removed: parser module, smtpd, asynchat, asyncore, distutils, lib2to3, imp module, pip from stdlib.

Old C APIs like PyEval_CallObject are removed. Py_UNICODE APIs are gone. Support for Windows 7/8 and macOS 10.9 ended.

C API Changes

Stable ABI extended. New PyCode_NewEmpty() for error reporting. PyObject_GC_Track() and friends are private.

Immortal objects reduce reference counting overhead. Vectorcall protocol is faster. C extensions must be recompiled.

Migration and Support

Most Python 3.11 code runs unchanged. Enable warnings with -W default to catch deprecations. Rebuild C extensions. Update code using removed modules.

Full support until October 2025, security fixes to October 2028. Use python -m venv for clean environments. Test with pyperformance to measure speed gains.

Releases In Branch 3.12

Version Release date
3.12.12 1 month ago
(October 09, 2025)
3.12.11 5 months ago
(June 03, 2025)
3.12.10 7 months ago
(April 08, 2025)
3.12.9 9 months ago
(February 04, 2025)
3.12.8 11 months ago
(December 03, 2024)
3.12.7 1 year ago
(October 01, 2024)
3.12.6 1 year ago
(September 06, 2024)
3.12.5 1 year ago
(August 06, 2024)
3.12.4 1 year ago
(June 06, 2024)
3.12.3 1 year ago
(April 09, 2024)
3.12.2 1 year ago
(February 06, 2024)
3.12.1 1 year ago
(December 07, 2023)
3.12.0 2 years ago
(October 02, 2023)
3.12.0rc3 2 years ago
(September 18, 2023)
3.12.0rc2 2 years ago
(September 05, 2023)
3.12.0rc1 2 years ago
(August 05, 2023)
3.12.0b4 2 years ago
(July 11, 2023)
3.12.0b3 2 years ago
(June 19, 2023)
3.12.0b2 2 years ago
(June 06, 2023)
3.12.0b1 2 years ago
(May 22, 2023)
3.12.0a7 2 years ago
(April 04, 2023)
3.12.0a6 2 years ago
(March 07, 2023)
3.12.0a5 2 years ago
(February 07, 2023)
3.12.0a4 2 years ago
(January 10, 2023)
3.12.0a3 2 years ago
(December 06, 2022)
3.12.0a2 3 years ago
(November 14, 2022)
3.12.0a1 3 years ago
(October 24, 2022)