python / python/cpython

Deprecate and Then Remove PyGILState_GetThisThreadState()

未關閉
#131,265 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

interpreter-core topic-C-API type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 PyGILState_GetThisThreadState() 的 C-API 文件項目開始,並將其中所述的行為與 PyThreadState_Get() 進行比較。確定已達成共識的棄用與移除範圍,包括是否必須保留任何內部 C-API 使用;完成的要求是制定出經 maintainer 核准的計畫,並完成相應的文件與實作變更。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
api
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。