Python free-threading guide introduction: Free-threaded CPython is coming. After PEP 703 acceptance and rollout strategy, work is happening in CPython and the ecosystem. This website is a centralized resource for package maintainers and end users.
- Tracking compatibility: The Compatibility Status Tracking shows the compatibility of packages with native code.
Installing and running free-threaded Python:
- Installing: Instructions on how to install free-threaded Python are provided at Installing Free-Threaded Python.
- Running with GIL disabled: Details on running Python with the GIL disabled are at Running Python with the GIL Disabled.
Updating code to run on free-threaded Python:
- Using Python libraries without maintenance: Experiment when dependencies support free-threading. If not using
threading
module and have no plans to, it's safe. For those usingthreading
module, read dependency docs on thread safety. Pure Python code may have thread safety issues, refer to Porting Python Packages to Support Free-Threading. - Maintaining pure Python app/tool: Similar to above but for apps/tools. If using
threading
module and have multithreaded tests, consider short thread switch interval. If not usingthreading
or thread pools, behavior should be the same under free-threading. - Maintaining pure Python package with public API: Pure Python code in CPython is thread-safe. Be cautious of creating thread safety issues like using global state, caches, or non-thread-safe dependencies. Test thread safety with multi-threaded tests (see our guide to adding multithreaded test coverage).
- Maintaining Python package with compiled extension modules: Dealing with native code takes work. Read the full porting guide including the section on native code considerations. Refer to Porting Python Packages to Support Free-Threading, Improving Multithreaded Test Coverage, and Updating Native Extensions to Support Free-Threading.
- Using Python libraries without maintenance: Experiment when dependencies support free-threading. If not using
Advanced topics for package maintainers:
- Setting up Continuous Integration: Setting up Continuous Integration.
- Debugging Thread Safety Issues: Debugging Thread Safety Issues.
- Further reading: More resources on free-threaded Python and multithreaded programming at More Resources.
- About this site: Contributions are welcome. Maintained by Quansight Labs working with the Python runtime team at Meta and stakeholders. Issues and pull requests can be opened on this repo.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。