This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petr.viktorin
Recipients christian.heimes, eric.snow, petr.viktorin, scoder, steve.dower, ta1hia, vstinner
Date 2019-09-27.08:46:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569573986.78.0.598314507503.issue38160@roundup.psfhosted.org>
In-reply-to
Content
> 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
History
Date User Action Args
2019-09-27 08:46:26petr.viktorinsetrecipients: + petr.viktorin, scoder, vstinner, christian.heimes, eric.snow, steve.dower, ta1hia
2019-09-27 08:46:26petr.viktorinsetmessageid: <1569573986.78.0.598314507503.issue38160@roundup.psfhosted.org>
2019-09-27 08:46:26petr.viktorinlinkissue38160 messages
2019-09-27 08:46:26petr.viktorincreate