Message353349
> only if PEP 573 makes it *compulsory* for heap types to contain a pointer to their module
And that's impossible without either breaking API (or some hackery).
PyType_FromSpec doesn't get the information, and it can be easily outside module initialization.
One possibility is to attach the __main__ module (or sys, or some synthetic module) to "module-less" classes, just to have something interpreter-specific there. But at that point, a dedicated "PyInterpreterState *" field starts looking like a better alternative.
It does complicate the "chain":
instance --> type -?> module --> interpreter
| ^
'-------------------'
But, one more thing that we need to think about is static types. Those are shared across interpreters; the "PyInterpreterState *" field should only be added to PyHeapTypeObject. ISTM that until we phase out static types entirely, you can't get the interpreter by following pointers from a type/instance anyway.
At that point, the opt-in approach of PEP 573 starts looking more attractive again:
instance --> type -?> module --> interpreter |
|
Date |
User |
Action |
Args |
2019-09-27 08:46:26 | petr.viktorin | set | recipients:
+ petr.viktorin, scoder, vstinner, christian.heimes, eric.snow, steve.dower, ta1hia |
2019-09-27 08:46:26 | petr.viktorin | set | messageid: <1569573986.78.0.598314507503.issue38160@roundup.psfhosted.org> |
2019-09-27 08:46:26 | petr.viktorin | link | issue38160 messages |
2019-09-27 08:46:26 | petr.viktorin | create | |
|