-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-127989: C API: Refer to attached thread states instead of the GIL #127990
Merged
+250
−190
Merged
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
ad7ee2d
Document the term 'thread state.'
ZeroIntensity bea045a
Change term for PyDict_GetItem
ZeroIntensity e286ba5
Change term for PyErr_Occurred
ZeroIntensity 6006b22
Change term for PyErr_SetInterrupt
ZeroIntensity 8dc3928
Change term for PyErr_SetInterruptEx
ZeroIntensity f46ca3d
Change term for PyConfig_Get
ZeroIntensity 555a03c
Change term for PyConfig_Names
ZeroIntensity ddb98cd
Change term for PyConfig_Set
ZeroIntensity 5d423f8
Change term for PyUnstable_AtExit
ZeroIntensity d2d2f67
Change term for Py_Initialize note
ZeroIntensity aa9c4c6
Change term for PyInterpreterState_Get
ZeroIntensity c05be67
Change term for PyInterpreterState_GetID
ZeroIntensity 3a69922
Change term for PyThreadState_SetAsyncEx
ZeroIntensity 3336ad7
Change term for Py_NewInterpreterFromConfig
ZeroIntensity 3991681
Change term for Py_FinalizeEx
ZeroIntensity 6d397eb
Change term for Py_AddPendingCall
ZeroIntensity 3b7b3ff
Change term for PyEval_SetProfile
ZeroIntensity 5358d14
Change term for PyEval_SetProfileAllThreads
ZeroIntensity 093ba05
Change term for PyEval_SetTrace
ZeroIntensity 11582fa
Change term for PyEval_SetTraceAllThreads
ZeroIntensity 3d55d2d
Change term for PyRefTracer_SetTracer
ZeroIntensity 2785c1d
Change term for PyRefTracer_GetTracer
ZeroIntensity 6d80b02
Change term for PyMutex_Lock
ZeroIntensity 94e046b
Change term for allocator domains
ZeroIntensity 713beb2
Change term for raw memory interface
ZeroIntensity 2140bde
Change term for memory interface
ZeroIntensity f608211
Change term for object allocators
ZeroIntensity d619387
Change term for PyMem_SetAllocator
ZeroIntensity e7828ed
Change term for PyMem_SetAllocator (again)
ZeroIntensity 6b33565
Change term for debug hooks
ZeroIntensity 6230177
Change term for debug hooks (again)
ZeroIntensity f74832a
Change term for PyState*
ZeroIntensity 7161fc0
Change term for various things
ZeroIntensity d58b74f
Change term for clock functions
ZeroIntensity a761c4a
Change term for raw clock functions
ZeroIntensity de122f5
Change term for tp_dealloc warning
ZeroIntensity 0b0176b
Change term for the types tutorial
ZeroIntensity c15f5c4
Add more information about thread states.
ZeroIntensity 0130b20
Change terms for 'cautions regarding runtime finalization'
ZeroIntensity a1e47b7
Simplify PyEval_SaveThread and PyEval_RestoreThread
ZeroIntensity 0173c46
Some more terminology fixups.
ZeroIntensity 166d970
Fix Sphinx build errors.
ZeroIntensity adae494
Change some usage of the term 'global interpreter lock'
ZeroIntensity a70ab11
Add some more terms for disambiguation.
ZeroIntensity 8584c86
Change usage of some terms.
ZeroIntensity 48b145a
Play around with terminology.
ZeroIntensity 8ce3d7d
Various terminology changes.
ZeroIntensity e5f1d18
Change the glossary definition a little bit.
ZeroIntensity 905ca5b
Change some phrasing.
ZeroIntensity f2826c4
Fix some usage of terms.
ZeroIntensity 5c44391
Change some usage of 'global interpreter lock'
ZeroIntensity 7d5877f
Fix pre-commit lint.
ZeroIntensity 283fc92
Delete redundant file
ZeroIntensity a7488ab
Revert "Delete redundant file"
ZeroIntensity 4c532b6
Remove accidental find-and-replace change.
ZeroIntensity 352acc5
Switch to a reference
ZeroIntensity ed550bc
Use a less wordy phrase for detaching.
ZeroIntensity d7cf403
Fix a typo in PyInterpreterState_Get
ZeroIntensity f61a6da
Change some wording in PyEval_SaveThread and PyEval_RestoreThread
ZeroIntensity 36af941
Change wording for PyThreadState_Swap
ZeroIntensity 0b23daa
Make glossary terms more clear.
ZeroIntensity 163b0b8
Change up wording for 'attached thread state'
ZeroIntensity 3b2bed8
Clarify that the C API is what needs a thread state.
ZeroIntensity 80ae46b
Update Doc/glossary.rst
ZeroIntensity 3dee63f
Update Doc/glossary.rst
ZeroIntensity 9ed3a0b
Drop the phrase 'current thread state' and only use 'attached thread …
ZeroIntensity b3cbbf8
Add extra note about free-threading.
ZeroIntensity 1c37d59
Add a seealso.
ZeroIntensity 32a4937
Merge from main.
ZeroIntensity 2fba67c
Fix weird merge artifact.
ZeroIntensity a0dc12c
Merge branch 'main' into clarify-gil-tstate
ZeroIntensity 94619f6
Change term for new PyConfig* APIs
ZeroIntensity e6f1f28
Change term for PyUnstable_InterpreterState_GetMainModule
ZeroIntensity 828d24b
Change term for Py_fopen
ZeroIntensity ace174f
Merge branch 'main' into clarify-gil-tstate
encukou 788d735
Change artifact from 'runtime context' to 'thread state'
ZeroIntensity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few points to consider, which are reflected in my other comments:
The only tricky part is that we already talk about "contexts" relative to asyncio.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll commit the suggestions tomorrow when I'm available to do a full find-and-replace so I don't blow up CI in the meantime.
For the per-thread thread state pointer (what a mouthful!), I'm happy with something like "runtime context," because there was no prior term for it, but I think we do want to keep the term "thread state." Thread states are documented, and users like to read the source code to understand some C functions--seeing
_PyThreadState_GET
and "thread state" in the documentation makes things more clear. That, and "context" doesn't convey the fact that it's a thread-local too well, which is important.Hmm, we do have "borrowed reference" and "strong reference" in there; where else should "thread state" point to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like "thread state" :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for sticking with thread state.
Between contextvars and context managers, and just the general idea of "context of execution", "context" is seriously overloaded already.
"thread state" isn't completely unambiguous (it could theoretically take on the holistic meaning of "all state associated with the current thread, including the execution stack and all thread local variables"), but the context(!) of use should help avoid that misinterpretation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Runtime context" in particular is problematic, since the execution model is set up with the hierarchy of: