Python 3.12 Release Notes
Release Date: October 2, 2023
Python 3.12 is a stable release focused on improvements in typing, performance, and language usability.
What's New in Python 3.12
Performance Improvements
- CPython optimizations and reduced memory usage:
- Removal of legacy internal Unicode fields (
wstr).
- Removal of legacy internal Unicode fields (
- Faster operations:
re.sub()up to ~2–3x faster in some cases.- Faster
asyncio.Taskcreation.
- Experimental support for the BOLT optimizer.
- General performance improvements across the standard library. :contentReference[oaicite:8]{index=8}
Language Changes
-
PEP 695: New type parameter syntax:
- More concise generics.
- New
typestatement for type aliases. :contentReference[oaicite:9]{index=9}
-
PEP 701: Formalized f-strings:
- Support for multiline expressions, comments, and more flexible syntax. :contentReference[oaicite:10]{index=10}
-
Improved error messages:
- Better suggestions and diagnostics. :contentReference[oaicite:11]{index=11}
Interpreter and Runtime
-
PEP 669: Low-impact monitoring API:
- Near-zero overhead profiling and debugging tools. :contentReference[oaicite:12]{index=12}
-
PEP 684: Per-interpreter GIL:
- Better isolation and scalability for multi-interpreter setups.
-
Linux
perfprofiler integration.
Typing
- PEP 692: Precise
**kwargstyping withTypedDict. - PEP 698:
typing.overridedecorator. - Improved typing ergonomics. :contentReference[oaicite:13]{index=13}
Standard Library
- Improvements in
asyncio(performance and features). - Enhancements to
os,pathlib, and other modules. - PEP 688: Buffer protocol accessible from Python. :contentReference[oaicite:14]{index=14}
Removals and Deprecations
- Removal of
distutilsfrom the standard library. :contentReference[oaicite:15]{index=15} - Cleanup of deprecated APIs and legacy features.
Internals
- CPython bytecode changes:
- Simplified and optimized instruction set.
- Improvements to C API and internal structures.
Migration Notes
When upgrading from Python 3.11:
- Replace
distutilswithsetuptools. - Review deprecated and removed APIs.
- Update typing-related code where needed.
- Test third-party dependencies.