Python 3.11 Release Notes
Release Date: October 24, 2022
Python 3.11 is a major release focused on performance, error reporting, and developer experience improvements.
What's New in Python 3.11
Performance Improvements
Python 3.11 is 10–60% faster than Python 3.10 on average.
- New specializing adaptive interpreter:
- Dynamically optimizes bytecode based on runtime behavior.
- Faster function calls and reduced overhead.
- “Zero-cost” exceptions:
- No performance penalty unless an exception is raised.
- Reduced memory usage for frames and objects.
Language and Exceptions
-
PEP 654: Exception Groups and
except*:- Handle multiple exceptions at once (useful for async/concurrent code). :contentReference[oaicite:0]{index=0}
-
PEP 678: Exceptions can include notes:
- Add additional context to errors.
-
PEP 657: Precise error locations:
- Tracebacks highlight exact expression positions. :contentReference[oaicite:1]{index=1}
Error Messages
- More informative and precise tracebacks.
- Better suggestions for common mistakes (e.g. NameError, AttributeError).
- Improved debugging experience overall.
Typing Improvements
- PEP 673:
Selftype for cleaner class method annotations. - PEP 646: Variadic generics.
- PEP 655: Required / NotRequired fields in
TypedDict. - PEP 675: Arbitrary literal string types.
- PEP 681: Data class transforms. :contentReference[oaicite:2]{index=2}
Standard Library
-
New module
tomllib:- Native read-only TOML parsing.
-
Improvements to
re:- Support for atomic grouping
(?>...). - Faster regex execution.
- Support for atomic grouping
-
Many updates across standard library modules.
Other Improvements
- Better debugging support (accurate line numbers, PEP 626).
- Improved startup time and internal optimizations.
- Experimental WebAssembly support groundwork.
Deprecations
- Start of removing legacy modules ("dead batteries") (PEP 594).
- Ongoing cleanup of deprecated APIs.
Migration Guide
When upgrading from Python 3.10:
- Most code works without changes.
- Review new warnings and deprecated modules.
- Test async and exception-heavy code for new behavior.