Python 3.13 Release Notes
Python 3.13.0, released on October 7, 2024, introduces major advancements in performance, concurrency, and developer experience. This version features an experimental free-threaded build without the Global Interpreter Lock (GIL) for better multi-core utilization, a new Just-In-Time (JIT) compiler, and a revamped interactive interpreter with multiline editing and colorized output. It also removes outdated modules as part of PEP 594, speeds up imports for many standard library components, and enhances error reporting.
Key focuses include experimental support for true parallelism, faster execution through optimizations like the adaptive interpreter, and improved tools for debugging and typing. Python 3.13 enters the new support model with two years of full support followed by three years of security fixes. These updates make it ideal for high-performance scripts, data analysis, web development, and more, while maintaining backward compatibility for most existing code.
Free-Threaded CPython
Experimental free-threaded builds, enabled with python3.13t, remove the GIL to allow true thread parallelism on multi-core systems. This is great for CPU-intensive tasks like numerical computations or parallel data processing.
Special builds are needed, and C extensions must be compatible. The GIL remains default for standard builds to ensure stability. New C APIs like Py_mod_gil and PyMutex support this mode.
Experimental JIT Compiler
The new JIT compiler, configurable via --enable-experimental-jit, uses LLVM to convert hot bytecode to machine code for faster runs. It builds on the adaptive interpreter from Python 3.11.
Enable it at runtime with python -X jit. Early benchmarks show gains in loops and function-heavy code, though it's still experimental and may evolve.
Improved Interactive Interpreter
The REPL now uses a PyPy-inspired implementation with multiline editing, colorized prompts and tracebacks, command history, and shortcuts like F1 for help or F2 for paste mode.
This makes interactive sessions more efficient and user-friendly. You can customize history file locations and disable colors if needed.
Defined Mutation Semantics for locals()
In optimized scopes, locals() returns a snapshot that does not reflect later changes. For exec or eval, provide an explicit namespace to capture mutations.
This clarifies behavior and prevents subtle bugs in dynamic code execution, improving reliability in functions with local variables.
Mobile Platform Support
Official tier-3 support for iOS (arm64-apple-ios and simulator) and Android (aarch64-linux-android and x86_64-linux-android) platforms, including binaries and testing.
This expands Python to mobile apps, allowing native scripting on devices without emulation.
Enhanced Error Messages
Better diagnostics for issues like naming conflicts with standard or third-party modules, and clearer feedback on invalid keyword arguments.
These improvements help developers spot and fix problems faster during coding and debugging.
New Typing Features
Type parameters now support default values, simplifying generic type definitions in libraries and applications.
This enhances code reusability and static analysis tools like mypy.
Other Language Changes
Docstrings strip leading/trailing whitespace automatically. Annotation scopes now allow lambdas and comprehensions. global statements work in except and else blocks.
New environment variable PYTHON_FROZEN_MODULES for frozen apps. Performance profiler support, __static_attributes__ for classes, __firstlineno__ for code objects, keyword args for exec/eval/compile, __name__ on properties, PythonFinalizationError, keyword count for str.replace(), warnings for boolean file descriptors, and new attributes for compressed file objects.
Module Improvements
argparse: add_argument and add_parser add a deprecated flag. array: New 'w' type for Unicode; implements MutableSequence.
ast: Stricter constructors; parse() takes optional optimize. asyncio: as_completed as async/plain iterator; auto-remove Unix sockets; zero-length datagrams; queue shutdown; server close methods; tuple separators in readuntil; improved TaskGroup cancellation; create_task with **kwargs.
configparser: Unnamed sections. ctypes: _align_ for structures; init in __init__. dbm: Default SQLite backend; clear() for GDBM/NDBM. dis: Logical labels over offsets; cache_info; show_offsets option.
email: Quoted headers with newlines; strict parsing flag. glob: translate() for wildcard-to-regex. itertools: batched() with strict. marshal: allow_code to block code objects. math: fma() for fused multiply-add.
mmap: Windows crash protection; seekable(); trackfd. os.path: isreserved() on Windows; isabs() fixes; realpath() for MS-DOS. pdb: Immediate breakpoint()/set_trace(); zipapp support; chained exceptions; better commands.
re: PatternError instead of re.error. shutil: chown() with dir_fd/follow_symlinks. site: UTF-8 first for .pth files. statistics: kde() and kde_random() for kernel density.
subprocess: More posix_spawn(); control flag. sys: _is_interned() for strings. time: Higher-res monotonic()/time() on Windows. tkinter: New widget methods, wm_attributes(), Text.count() as int, vsapi, after_info(), copy_replace(), read()/data().
types: SimpleNamespace from mappings/iterables. venv: SCM ignore files. zipimport: ZIP64 support.
Performance Optimizations
Import times improved for modules like typing, email.utils, enum, functools, importlib.metadata, and threading. textwrap.indent() is about 30% faster for large strings.
subprocess launch speeds up with wider posix_spawn() use on modern systems. These changes reduce startup and runtime overhead in everyday scripts and applications.
Deprecations
Assignment to __code__ with mismatched types. 'u' format in array (use 'w'). ctypes.SetPointerType() and ARRAY() (use multiplication). decimal.Decimal 'N' format.
dis.HAVE_ARGUMENT (use hasarg). Non-integer plurals in gettext. Undocumented glob0()/glob1() (use glob() with root_dir). http.server.CGIHTTPRequestHandler and --cgi. Positional maxsplit/count/flags in re.split()/sub()/subn().
platform.java_ver(). pydoc.ispackage(). Specific deprecations in sqlite3, sys, tarfile.TarFile.tarfile, traceback, typing (keyword args for NamedTuple, omitting fields, no_type_check_decorator(), AnyStr), and wave.
Removals
PEP 594 removes "dead batteries": aifc, audioop, cgi, cgitb, chunk, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu, xdrlib.
Remove 2to3 tool and lib2to3. tkinter.tix. locale.resetlocale(). typing.io and typing.re. Chained classmethod descriptors. opcode.is_pseudo(), MIN_PSEUDO_OPCODE, MAX_PSEUDO_OPCODE, ENABLE_SPECIALIZATION.
re.template(), re.TEMPLATE/re.T. pathlib.Path context manager. webbrowser.MacOSX and _name. turtle.RawTurtle.settiltangle(). configparser.LegacyInterpolation. Various private C APIs and macros like Py_TRASHCAN_SAFE_BEGIN/END.
Other Changes
Build system requires C11 atomics, newer Autoconf, SQLite 3.15.2+, bundles mimalloc, defaults to system libmpdec. Platforms: iOS/Android tier-3, wasm32-wasi tier-2, wasm32-emscripten unsupported.
C API favors PyConfig for init; updates to trashcan macros; removals of private headers/functions. Porting notes cover locals() semantics, exec/eval namespaces, functools.partial as method, getpass.getuser() errors, gzip/zipfile modes, mailbox.Maildir dots, pathlib.glob with **, threading._thread expectations.
Migration and Support
Upgrading from 3.12 is straightforward; run with warnings enabled to spot deprecations. Rebuild C extensions for free-threaded or JIT modes. Update code for removed modules and new locals() behavior.
Full support until October 2026, security fixes to October 2029. Test imports and multiprocessing for changes. Documentation provides detailed porting guides for smooth transitions.