`PyType_GetModuleByDef` is really slow.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
PyType_GetModuleByDef does a lot of work for what was a single memory read prior to sub-interpreters.
For example, https://github.com/python/cpython/issues/114682.
We should provide a more efficient way to get to the module state from the module def.
AFAICT, the function to get the module state is a pure function of the interpreter and the module def.
Since the module def already has a m_index field that is described as "The module's index into its interpreter's modules_by_index cache.", then a Py_GetModuleFromDef() function could be as simple as:
inline PyObject *
Py_GetModuleFromDef(PyModuleDef *def)
{
return PyInterpreterState_Get()->modules_table[def->m_base.m_index];
}
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
Beginne mit PyType_GetModuleByDef, PyModuleDef.m_index und dem im Issue genannten modules_by_index-Cache des Interpreters. Vergleiche den aktuellen Lookup-Pfad mit der vorgeschlagenen module-from-definition-API und stelle sicher, dass das Verhalten pro Interpreter korrekt bleibt und gleichzeitig der gemeldete Overhead behoben wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, python
- Bereich
- backend-api-design, performance
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100