gh-146636: Add Free-threaded Stable ABI migration guide#150580
gh-146636: Add Free-threaded Stable ABI migration guide#150580encukou wants to merge 25 commits into
Conversation
This document provides detailed instructions on how to use the Free Threading Stable ABI in CPython, including guidelines for module initialization, API usage, and thread safety considerations.
Clarified access restrictions on PyObject members and recommended functions for type and reference count manipulation.
Clarified that direct access to PyObject members is prohibited.
Updated documentation to clarify the identification of free-threaded limited API builds in C, including changes to macros and initialization methods.
Updated the documentation to clarify the use of the stable ABI and GIL management in Python extensions, including changes to member access and initialization methods.
Removed sections on API guidelines, critical sections, and thread safety from the documentation.
Documentation build overview
28 files changed ·
|
|
Thanks, this looks great! I'll probably use the tables in my EuroPython talk. I'm hopeful that we'll be able to ship abi3t support in the next releases of PyO3 and Maturin (see PyO3/pyo3#5807 and PyO3/maturin#3113). I am also planning to add a section to the free-threaded guide about building abi3t extensions, including practicalities like dealing with bindings generators and the NumPy C API. When that is ready, maybe we can just link there for all the ecosystem-wide details that don't belong in the CPython docs? |
| +-----------------+-------------------+------------------+ | ||
| | 3.16 | ``cpython-316`` | ``cpython-316t`` | | ||
| +-----------------+-------------------+------------------+ | ||
| | Future versions | (etc.) | (etc.) | |
There was a problem hiding this comment.
| | Future versions | (etc.) | (etc.) | | |
| | Future versions | ``cpython-X`` | ``cpython-Xt`` | |
I suggest this to avoid the Latin abbreviation, which per the devguide we discourage.
| +-----------------+ +------------------+ | ||
| | 3.16 | | ``cpython-316t`` | | ||
| +-----------------+ +------------------+ | ||
| | Future versions | | (etc.) | |
There was a problem hiding this comment.
| | Future versions | | (etc.) | | |
| | Future versions | | ``cpython-Xt`` | |
Ditto.
| changes extensions may need. | ||
|
|
||
| If you find a problem that other extension authors might run into, | ||
| consider submitting an issue (or pull request) for this guide. |
There was a problem hiding this comment.
Maybe add a link to https://docs.python.org/3/bugs.html?
Co-authored-by: da-woods <dw-git@d-woods.co.uk> Co-authored-by: Stan Ulbrych <stan@python.org>
|
Thanks for the reviews and suggestions!
That sounds great! |
| ****************************************************** | ||
| Migrating to Stable ABI for Free Threading (``abi3t``) | ||
| ****************************************************** |
There was a problem hiding this comment.
Use sentence case for headers:
https://devguide.python.org/documentation/style-guide/#capitalization
| ****************************************************** | |
| Migrating to Stable ABI for Free Threading (``abi3t``) | |
| ****************************************************** | |
| ****************************************************** | |
| Migrating to Stable ABI for free threading (``abi3t``) | |
| ****************************************************** |
| +-----------------+-----------------------+------------------------+ | ||
| | 3.16 | ``cpython-316`` | ``cpython-316t`` | | ||
| +-----------------+-----------------------+------------------------+ | ||
| | Later versions | :samp:`cpython-3{YY}` | :samp:`cpython-3{YY}t` | |
There was a problem hiding this comment.
I suggest XX as the first unknown, to avoid any confusion with YY for the year in CalVer, and the similar "3.x" is more common than "3.y".
| | Later versions | :samp:`cpython-3{YY}` | :samp:`cpython-3{YY}t` | | |
| | Later versions | :samp:`cpython-3{XX}` | :samp:`cpython-3{XX}t` | |
| +-----------------+ +------------------------+ | ||
| | 3.16 | | ``cpython-316t`` | | ||
| +-----------------+ +------------------------+ | ||
| | Later versions | | :samp:`cpython-3{YY}t` | |
There was a problem hiding this comment.
| | Later versions | | :samp:`cpython-3{YY}t` | | |
| | Later versions | | :samp:`cpython-3{XX}t` | |
| Extensions need to be ported to build for Stable ABI, which may be difficult | ||
| or, in rare cases, impossible. | ||
|
|
||
| Specifically, ``abi3t`` requires on API added in CPython 3.15. |
There was a problem hiding this comment.
?
| Specifically, ``abi3t`` requires on API added in CPython 3.15. | |
| Specifically, ``abi3t`` requires an API added in CPython 3.15. |
| .. seealso:: | ||
|
|
||
| `Porting Extension Modules to Support Free-Threading | ||
| <https://py-free-threading.github.io/porting/>`_: |
There was a problem hiding this comment.
Prefer anon links:
| <https://py-free-threading.github.io/porting/>`_: | |
| <https://py-free-threading.github.io/porting/>`__: |
| Isolating Extension Modules | ||
| --------------------------- |
There was a problem hiding this comment.
| Isolating Extension Modules | |
| --------------------------- | |
| Isolating extension modules | |
| --------------------------- |
| return my_slot_array; | ||
| } | ||
|
|
||
| Leave out any fields that were missing (excexpt the new :c:macro:`Py_mod_abi`), |
There was a problem hiding this comment.
| Leave out any fields that were missing (excexpt the new :c:macro:`Py_mod_abi`), | |
| Leave out any fields that were missing (except the new :c:macro:`Py_mod_abi`), |
| your classes' data, will need to be rewritten. | ||
| This will probably be the biggest change you need to support ``abi3t``. | ||
|
|
||
| For each such type: |
There was a problem hiding this comment.
The steps following this could be a bullet list.
|
|
||
| If you distribute the extension as a *wheel*, use the following tags: | ||
|
|
||
| * Python tag: :samp:`cp3{YY}`, where *YY* is the minimum Python version |
There was a problem hiding this comment.
| * Python tag: :samp:`cp3{YY}`, where *YY* is the minimum Python version | |
| * Python tag: :samp:`cp3{XX}`, where *XX* is the minimum Python version |
Uh oh!
There was an error while loading. Please reload this page.