Improved performance and arguably simpler code for dictionaries by changing the keys layout
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Current layout
Currently the _dictkeysobject struct is laid out like this:
ptr ----> +--------------+
| header |
+--------------+
| indices |
+--------------+
| keys |
+--------------+
which requires some relatively expensive calculation to find the start of the keys, as the indices are not only variable in number, but variable in size also.
Proposed layout
If instead it is laid out as follows:
+--------------+
| indices |
ptr ----> +--------------+
| header |
+--------------+
| keys |
+--------------+
and the indices laid from highest to lowest with 0 just before ptr, finding the start of the keys is as simple as ptr->keys . Accessing an index is no slower, and the code barely any more complex.
Linked PRs
- gh-145097
- gh-150640
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Prüfe zuerst das vorgeschlagene _dictkeysobject-Layout und die verknüpften PRs gh-145097 und gh-150640, da sich die Arbeit dorthin verlagert hat. Vergleiche die aktuelle und die vorgeschlagene Anordnung von Index, Header und Keys; für den Abschluss wären die Implementierung und ihre Performance- oder Korrektheitsvalidierung erforderlich, um das neue Layout zu unterstützen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100