Merged
Conversation
ngoldbaum
approved these changes
Oct 27, 2025
Contributor
ngoldbaum
left a comment
There was a problem hiding this comment.
Super minor nits but otherwise looks great.
| A module can opt-out of supporting free-threaded Python until it has audited its `unsafe` code for correctness by declaring the module with `#[pymodule(gil_used = true)]` (see below). | ||
|
|
||
| More complicated `#[pyclass]` types may need to deal with thread-safety directly; there is [a dedicated section of the guide](./class/thread-safety.md) to discuss this. | ||
| Complicated `#[pyclass]` types may need to deal with thread-safety directly; there is [a dedicated section of the guide](./class/thread-safety.md) to discuss this. |
Contributor
There was a problem hiding this comment.
Want me to go over these docs once more to see if they still make sense with the new default?
Member
Author
There was a problem hiding this comment.
Keeping docs fresh is always much appreciated! I think I got everything but will never say no to another pair of eyes 😄
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
Hooksie
reviewed
Nov 18, 2025
| } | ||
| }; | ||
|
|
||
| // By default, PyO3 assumes modules use the GIL for thread safety. |
Contributor
There was a problem hiding this comment.
Isn't this statement backwards?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #5525 which has switched the default
gil_usedflag tofalseas part of that diff, also default modules created withPyModule::newto not require the GIL. This PR also takes the opportunity to add documentation to the migration guide.