@@ -389,16 +389,18 @@ subinterpreters:
389389
390390- :c:func: `PyGILState_Ensure `: :c:func: `PyThreadState_Swap ` & :c:func: `PyThreadState_New `
391391- :c:func: `PyGILState_Release `: :c:func: `PyThreadState_Clear ` & :c:func: `PyThreadState_Delete `
392- - :c:func: `PyGILState_GetThisThreadState `: :c:func: `PyThreadState_Get `
392+ - :c:func: `PyGILState_GetThisThreadState `: :c:func: `PyThreadState_Get ` (roughly)
393393- :c:func: `PyGILState_Check `: ``PyThreadState_GetUnchecked() != NULL ``
394394
395- This PEP specifies a ten-year deprecation for these functions (while remaining
396- in the stable ABI), mainly because it's expected that the migration will be a
397- little painful, because :c:func: `PyThreadState_Ensure ` and
398- :c:func: `PyThreadState_Release ` aren't drop-in replacements for
395+ This PEP specifies a deprecation for these functions (while remaining
396+ in the stable ABI), because :c:func: `PyThreadState_Ensure ` and
397+ :c:func: `PyThreadState_Release ` will act as more-correct replacements for
399398:c:func: `PyGILState_Ensure ` and :c:func: `PyGILState_Release `, due to the
400- requirement of a specific interpreter. The exact details of this deprecation
401- aren't too clear, see :ref: `pep-788-deprecation `.
399+ requirement of a specific interpreter.
400+
401+ The exact details of this deprecation aren't too clear. It's likely that
402+ the usual five-year deprecation (as specificed by :pep: `387 `) will be too
403+ short, so for now, these functions will have no specific removal date.
402404
403405Specification
404406=============
@@ -583,14 +585,25 @@ existing and new ``PyThreadState`` APIs. Namely:
583585 instead.
584586
585587All of the ``PyGILState`` APIs are to be removed from the non-limited C API in
586- Python 3.25. They will remain available in the stable ABI for compatibility.
588+ a future Python version. They will remain available in the stable ABI for
589+ compatibility.
590+
591+ It's worth noting that :c:func:`PyThreadState_Get` and
592+ :c:func:`PyThreadState_GetUnchecked` aren't perfect replacements for
593+ :c:func:`PyGILState_GetThisThreadState`, because
594+ :c:func:`PyGILState_GetThisThreadState` is able to return a thread state even
595+ when it is :term:`detached <attached thread state>`. This PEP intentionally
596+ doesn't leave a perfect replacement for this, because the GIL-state pointer
597+ (which holds the last used thread state by the thread) is only useful for
598+ those implementing :c:func:`PyThreadState_Ensure` or similar. It's not a
599+ common API to want as a user.
587600
588601Backwards Compatibility
589602=======================
590603
591604This PEP specifies a breaking change with the removal of all the
592- ``PyGILState`` APIs from the public headers of the non-limited C API in 10
593- years (Python 3.25) .
605+ ``PyGILState`` APIs from the public headers of the non-limited C API in a
606+ future version .
594607
595608Security Implications
596609=====================
@@ -780,8 +793,9 @@ This is the same code, rewritten to use the new functions:
780793 Example: A Daemon Thread
781794************************
782795
783- Native daemon threads are still a use-case, and as such,
784- they can still be used with this API:
796+ With this PEP, daemon threads are very similar to how native threads are used
797+ in the C API today. After calling :c:func: `PyThreadState_Ensure `, simply
798+ release the interpreter reference, allowing the interpreter to shut down.
785799
786800.. code-block :: c
787801
@@ -1038,21 +1052,7 @@ under that category.
10381052Open Issues
10391053===========
10401054
1041- .. _pep-788-deprecation:
1042-
1043- When Should the GIL-state APIs be Removed?
1044- ------------------------------------------
1045-
1046- :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` have been around
1047- for over two decades, and it's expected that the migration will be difficult.
1048- Currently, the plan is to remove them in 10 years (opposed to the 5 years
1049- required by :pep: `387 `), but this is subject to further discussion, as it's
1050- unclear if that's enough (or too much) time.
1051-
1052- In addition, it's unclear whether to remove them at all. A
1053- :term:`soft deprecation <soft deprecated>` could reasonably fit for these
1054- functions if it's determined that a full ``PyGILState`` removal would
1055- be too disruptive for the ecosystem.
1055+ There are currently no open issues for this PEP.
10561056
10571057Copyright
10581058=========
0 commit comments