python / python/cpython

Deprecate and Then Remove PyGILState_GetThisThreadState()

Aperta
#131,265 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

interpreter-core topic-C-API type-feature
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalla voce della documentazione della C-API per PyGILState_GetThisThreadState() e confronta il comportamento dichiarato con quello di PyThreadState_Get(). Determina l'ambito concordato della deprecazione e della rimozione, incluso se debba rimanere qualche utilizzo interno della C-API; il lavoro sarà considerato completato quando saranno disponibili un piano approvato da un maintainer e le modifiche corrispondenti alla documentazione e all'implementazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.