iTranslated by AI
Python 3.13 is officially released!
Summary of Python 3.13 New Features and Changes
Python 3.13, the latest stable version of the Python programming language, has been officially released.

In this article, based on the Python 3.13 Release Notes, I will explain the major changes and new features from the previous version (Python 3.12).
Highlights
In Python 3.13, various changes have been made to the language itself, the implementation, and the standard library. The main changes are as follows:
- Introduction of a new interactive interpreter: A new interactive shell that significantly improves the user experience is now the default.
- Experimental support for free-threaded mode (PEP 703): It is now possible to run Python code with the Global Interpreter Lock (GIL) disabled.
- Addition of a Just-In-Time (JIT) compiler (PEP 744): A JIT compiler aimed at performance improvements has been introduced experimentally.
Furthermore, error messages continue to be improved, and tracebacks are now displayed in color by default. Additionally, the behavior of the locals() built-in function has been clarified, and default values are now supported for type parameters.
Interpreter Improvements
New Interactive Interpreter
A new interactive shell based on code from the PyPy project is now the default. Key features include:
- Multi-line editing and history preservation: Editing code across multiple lines is now possible, and history is preserved.
-
Support for direct REPL commands: Commands like
help,exit, andquitcan be used without function calls. - Color display: Prompts and tracebacks are displayed in color by default.
- Interactive help browsing: You can browse help by pressing the F1 key.
- History browsing: You can browse history (excluding output and prompts) by pressing the F2 key.
- Paste mode: Pasting large blocks of code is made easier with the F3 key.
To disable the new interactive shell, set the environment variable PYTHON_BASIC_REPL.

Error Message Improvements
-
Colored tracebacks: Tracebacks in the terminal are now displayed in color by default. This can be controlled via environment variables
PYTHON_COLORS,NO_COLOR, andFORCE_COLOR. - Warnings regarding module name conflicts: More specific error messages are displayed when a user script name conflicts with a standard library or third-party module name.
- Keyword argument typo detection: When an incorrect keyword argument is passed, suggestions for the correct argument name are displayed.
Free-threaded CPython (PEP 703)
Free-threaded mode, which disables the Global Interpreter Lock (GIL), is now experimentally supported. This allows threads to run in parallel, utilizing multi-core CPUs. However, this feature is still experimental and disabled by default.
-
Usage: Use the special executable provided as
python3.13torpython3.13t.exe. -
Activation: Build from source using the
--disable-giloption, or select the free-threaded version in the official installer. - Notes: Bugs and decreased single-threaded performance are expected at this stage. Improvements are planned for future releases.
Just-In-Time (JIT) Compiler (PEP 744)
An experimental JIT compiler has been added. Performance gains are currently limited, and it is disabled by default. It is expected to be refined in future releases with the goal of improving performance.
Data Model Improvements
-
Addition of the
__static_attributes__attribute: Stores attribute names accessed viaself.Xin functions within the class body. -
Addition of the
__firstlineno__attribute: Records the first line number of the class definition.
Major Changes to the Standard Library
-
Addition of the new exception
PythonFinalizationError: This exception is raised when an operation is blocked during finalization. -
argparsemodule extensions: Support for deprecating command-line options, positional arguments, and subcommands has been added. -
base64module extensions:z85encode()andz85decode()functions have been added, enabling the encoding and decoding of Z85 data. -
copymodule enhancements: Thecopy.replace()function has been added, supported by many built-in types and classes that define the__replace__()method. -
New
dbm.sqlite3module: SQLite3 is now used as the defaultdbmbackend. -
osmodule extensions: New functions have been added for operating Linux timer notification file descriptors. -
randommodule command-line interface: Therandommodule can now be used directly from the command line.
Security Improvements
-
Hardened SSL default settings:
ssl.create_default_context()now sets thessl.VERIFY_X509_PARTIAL_CHAINandssl.VERIFY_X509_STRICTflags by default.
C API Improvements
-
Explicit GIL support for extension modules: The
Py_mod_gilslot is used to indicate that an extension module supports execution with the GIL disabled. -
Access to system clocks: New
PyTimeC APIs have been added. -
Addition of a lightweight mutex
PyMutex: A 1-byte lightweight mutex (PyMutex) has been provided. - Support for PEP 669 monitoring events: A new set of functions has been added to the C API, allowing for the generation of monitoring events.
New Features in typing
-
PEP 696: Support for default values in type parameters: Default values are now supported in
typing.TypeVar,typing.ParamSpec, andtyping.TypeVarTuple. -
PEP 702: Addition of the
warnings.deprecated()decorator: A decorator has been added to mark deprecations both in the type system and at runtime. -
PEP 705: Addition of
typing.ReadOnly: Items in atyping.TypedDictcan now be marked as read-only for type checkers. -
PEP 742: Addition of
typing.TypeIs: A new type constructor has been added that provides more intuitive behavior for type narrowing.
Platform Support
- PEP 730: Official support for iOS: Apple's iOS is now supported as a Tier 3 platform.
- PEP 738: Official support for Android: Android is now supported as a Tier 3 platform.
-
Support for
wasm32-wasi: Now supported as a Tier 2 platform. -
End of support for
wasm32-emscripten: Removed from the list of officially supported platforms.
Important Removals
PEP 594: Removal of Dead Standard Library Modules
The following 19 modules have been removed from the standard library (deprecated in Python 3.11):
aifcaudioop-
cgi,cgitb chunkcryptimghdrmailcapmsilibnisnntplibossaudiodevpipessndhdrspwdsunautelnetlibuuxdrlib
If you need the functionality of these modules, consider third-party libraries or alternatives.
Other Removals
-
Removal of the
2to3tool andlib2to3module (deprecated in Python 3.11) -
Removal of the
tkinter.tixmodule (deprecated in Python 3.6) - Removal of the
locale.resetlocale()function - Removal of the
typing.ioandtyping.renamespaces - Removal of chained
classmethoddescriptors
Changes to the Release Schedule
With the update of PEP 602, the full support period (bugfix period) for new releases has been extended to 2 years.
- Python 3.9–3.12: 1.5 years of full support and 3.5 years of security fixes
- Python 3.13 and later: 2 years of full support and 3 years of security fixes
Details of New Features
Details of the New Interactive Interpreter
The new interactive shell offers the following advantages:
- Multi-line code editing is easier, and history is preserved.
- Standard commands (such as
help,exit,quit, etc.) can be used without function calls. - Color display improves code readability.
- You can browse interactive help with the F1 key.
- You can efficiently refer to past input history with the F2 key.
- You can switch to paste mode with the F3 key, making it easier to paste large blocks of code.
Details of Error Message Improvements
- Tracebacks in the terminal are displayed in color by default, making it easier to identify errors.
- If a script name conflicts with a standard library or third-party module name, a specific error message is displayed, allowing for quick problem resolution.
- If an incorrect keyword argument is passed, the correct argument name is suggested, facilitating easier debugging.
Other Language Changes
- Removal of leading whitespace from docstrings: To reduce the size of the bytecode cache, common leading whitespace is now removed from each line of docstrings.
- Support for lambda expressions and comprehensions in class scopes: Lambda expressions and comprehensions are now supported in annotation scopes within class scopes.
-
Change in handling of the
__future__module via relative imports: Relative imports of the__future__module no longer enable its special features. -
Allowing
globaldeclarations inexceptblocks: Global variables used in anelseblock can now be declared withglobalwithin theexceptblock.
Conclusion
Thank you for reading until the end. If there are any deficiencies, please feel free to point them out in the comments.
Note: This article is a copy of my Qiita article.
Discussion
あなた、すごいわ!
17歳って・・・、将来のコンピューター業界、あなたのような人がいると楽しみですね。
是非、私に不明点等あった際には色々教えていただけたら幸いです。
これからもいっぱい頑張ってください。