python / python/cpython

We have run out of flags bits in `PyTypeObject`'s `tp_flags`

Offen
#134,860 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

interpreter-core topic-C-API type-feature
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

PyTypeObject's tp_flags field is defined as an unsigned long. In effect this means that we have only 32 bits we can use for flags. We have already used all 32 of them.

Bits 15 and 16 are reserved for Stackless Python. Since Stackless Python is pining for the fjords, we could recycle those two bits. However that's not going to last long with likely changes necessary for parallelism and performance.

Any change to PyTypeObject breaks both API and ABI, but that's OK because:

  • Adding a field or changing the size of a field is a backwards compatible API change.
  • The existence of PyTypeObject is part of the stable ABI, but its layout is not.

The cleanest change, IMO, is to change unsigned long tp_flags to uint64_t tp_flags which gives us another 32 bits, which should last many more years.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Definition von PyTypeObject und allen Verwendungen seines Feldes tp_flags und bewerten Sie anschließend die vorgeschlagene Änderung der Breite anhand der genannten API- und ABI-Einschränkungen. Als abgeschlossen gilt die Aufgabe, wenn ein abgestimmtes Design zur Erweiterung der verfügbaren Flag-Bits erreicht und implementiert wurde und die betroffenen Schnittstellen sowie das Kompatibilitätsverhalten berücksichtigt sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.