Description
Feature or enhancement
Proposal:
(See https://docs.python.org/3/c-api/init.html#c.PyGILState_GetThisThreadState.)
PyGILState_GetThisThreadState()
was added as part of the PEP 311 implementation. However, it wasn't part of that proposal. It isn't clear that it was even meant to be public API.
If a user wants to know what the current thread state is then they should use PyThreadState_Get()
. PyGILState_GetThisThreadState()
is subtly different and surfaces some of the tricky PyGILState
corner cases that PyThreadState_Get()
blissfully ignores. A real issue here is that users are reasonably likely to stumble across PyGILState_GetThisThreadState()
and, due to the name, use it instead of the proper API.
I can think of one thing that PyGILState_GetThisThreadState()
does exclusively: it will tell you what existing thread state PyGILState_Ensure()
will use, if any. It isn't clear to me if that's a meaningful use case.
Ultimately, I expect we would be fine to get rid of PyGILState_GetThisThreadState()
. If still useful for core development, it could be moved to the internal C-API.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response