Release Date: October 7, 2024
Key Focus: Free-Threaded CPython (Experimental GIL Removal), Experimental JIT Compiler, Improved Interactive REPL, Type Narrowing (TypeIs), ReadOnly, and Default Type Parameters.
Introduced experimental support for building CPython with the Global Interpreter Lock (GIL) disabled (--disable-gil). This allows threads to run in true multi-threaded CPU parallel fashion across multiple CPU cores within the same interpreter process.
Added an experimental JIT compiler to CPython. When enabled (--enable-experimental-jit), CPython compiles bytecode into machine code at runtime using a lightweight copy-and-patch JIT mechanism, yielding further performance speedups.
Replaced Python's standard interactive prompt with an enhanced terminal REPL based on PyPy's CLI interface:
- Multi-line code editing with syntax highlighting.
- Colorized tracebacks and interactive help menus.
- Dedicated paste mode (
F3/%paste). - Shell command navigation and improved history inspection.
Introduced TypeIs to replace TypeGuard for type narrowing predicate functions. TypeIs allows static type checkers to narrow types in both if (True) and else (False) branches symmetrically.
Type variables and type parameters can now specify default types:
type Vector[T = float] = list[T] or T = TypeVar("T", default=str).
Added ReadOnly[] modifier to TypedDict key definitions to mark keys that cannot be modified or updated after dictionary creation.
Added dbm.sqlite3 as a standard portable key-value storage backend built on top of SQLite3.
| PEP | Feature | Description |
|---|---|---|
| PEP 703 | Free-Threaded CPython | Experimental build option to run without the GIL |
| PEP 744 | JIT Compiler | Experimental copy-and-patch JIT compiler for CPython |
| PEP 742 | typing.TypeIs |
Precise symmetric type narrowing predicates |
| PEP 696 | TypeVar Defaults | Default types for generic type parameters |
| PEP 702 | @warnings.deprecated |
Standard decorator to mark functions/classes as deprecated |
Check main_3_13.py in this directory for runnable code examples demonstrating:
- Precise type narrowing predicates using
TypeIs - Generic type parameter defaults (
TypeVardefaults) - Read-only schema definitions using
TypedDictandReadOnly - Deprecation warnings using
@warnings.deprecated - Free-threading and JIT architecture overview