◐ Shell
reader mode source ↗
Skip to content

gh-146636: Add Free-threaded Stable ABI migration guide#148453

Closed
clin1234 wants to merge 18 commits into
python:mainfrom
clin1234:patch-6
Closed

gh-146636: Add Free-threaded Stable ABI migration guide#148453
clin1234 wants to merge 18 commits into
python:mainfrom
clin1234:patch-6

Conversation

@clin1234

@clin1234 clin1234 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

@bedevere-app bedevere-app Bot added awaiting review docs Documentation in the Doc dir skip news labels Apr 12, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Apr 12, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Apr 12, 2026
9 tasks

@da-woods da-woods left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

There's a lot that isn't right here (or is mostly about freethreading generally rather than about the stable ABI).

@da-woods

Copy link
Copy Markdown
Contributor

I think the way most people will want to proceed is:

  1. Switch to PEP 793 module initialization (https://peps.python.org/pep-0793/). This will hopefully be a fairly trivial change for most people.
  2. Switch to using opaque objects and accessing all their type data through PyObject_GetTypeData. This will be a painful change for most people (and especially if they're starting from static types).
  3. Follow the general free-threading C API advice in https://docs.python.org/3/howto/free-threading-extensions.html#container-thread-safety (e.g. avoid borrowed reference, use critical sections once they become available). My personal opinion is that it isn't worth duplicating the advice.
  4. Decide if they want to mark their extension as thread-safe.

But steps 1 and 2 are the main ones and are almost not covered here.

@clin1234

clin1234 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor Author

Based on WIP PR: #148013

@picnixz

picnixz commented Apr 12, 2026

Copy link
Copy Markdown
Member

I don't understand why we are having this PR when the reference documentation is not merged. Can we revisit this later? I would have expected the PEP's author to write this.

@picnixz picnixz marked this pull request as draft April 12, 2026 17:03
@clin1234 clin1234 marked this pull request as ready for review April 12, 2026 17:44
@picnixz

picnixz commented Apr 13, 2026

Copy link
Copy Markdown
Member

I left it as a draft because I do not think it is time for it to be reviewed. Please wait for the PEP author first.

@encukou

encukou commented Apr 13, 2026

Copy link
Copy Markdown
Member

Please don't repeat text from free-threading HOWTO. This document should be about migrating from that to the stable ABI; anything that's relevant to free-threading in general should be explained there (and possibly linked from the new document).

Also don't repeat information from the reference docs. A migration guide should link to the docs, and perhaps point out how/why the new thing is different.

And please see here on how-to guides in general: https://diataxis.fr/how-to-guides/

@read-the-docs-community

read-the-docs-community Bot commented May 2, 2026

Copy link
Copy Markdown

@clin1234 clin1234 requested a review from da-woods May 7, 2026 19:31
@clin1234 clin1234 marked this pull request as draft May 7, 2026 19:31
@clin1234 clin1234 marked this pull request as ready for review May 17, 2026 09:33
clin1234 added 5 commits May 17, 2026 05:33
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.
clin1234 and others added 9 commits May 17, 2026 05:33
Clarified that direct access to PyObject members is prohibited.
Co-authored-by: da-woods <dw-git@d-woods.co.uk>
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.
@encukou

encukou commented May 28, 2026

Copy link
Copy Markdown
Member

Thank you @clin1234. I'll take it from here.

@clin1234

Copy link
Copy Markdown
Contributor Author

Thank you @clin1234. I'll take it from here.

Any other major PRs as part of implementing PEP 803 that should be mentioned in the Migration Guide?

@encukou

encukou commented May 29, 2026

Copy link
Copy Markdown
Member

Continued in #150580.

Any other major PRs as part of implementing PEP 803 that should be mentioned in the Migration Guide?

Mentions should go in Release notes; a guide should rather be full of practical advice.
All the PRs should be attached to #146636 though.

@encukou encukou closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review DO-NOT-MERGE docs Documentation in the Doc dir

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants