-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-94673: Add Per-Interpreter Storage for Static Builtin Types #94995
gh-94673: Add Per-Interpreter Storage for Static Builtin Types #94995
Conversation
For context, I have a branch on top of this one that takes care of tp_subclasses: main...ericsnowcurrently:shareable-static-types-tp_subclasses. |
Thanks for working on this! Mostly LGTM, a few changes worth looking into:
|
There should be no performance impact since it's still a single static offset from the pointer we were already dereferencing.
None of the other fields have a leading underscore, even the ones that are documented as internal. That does remind me, I should also add the new field to the docs. (Or maybe I'll ditch the new field and not worry about it. 🙂) |
@@ -65,6 +65,7 @@ lookup_maybe_method(PyObject *self, PyObject *attr, int *unbound); | |||
static int | |||
slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test_embed failure is because |
FYI, I tried printing some diagnostic info in minimal:
This boils down to static type subclasses in extension modules, since they don't get finalized (ever). Maybe we should ignore static types in tp_subclasses... a more complex case
|
To solve the test_embed failure, I had to stop ignoring types in |
I'm going to split this PR up. |
This is a precursor to storing tp_subclasses (and tp_weaklist) on the interpreter state for static builtin types. At a high level, we add the following:
_PyStaticType_InitBuiltin()
PyInterpreterState.types.builtins
We also shuffle some code around to be able to use
_PyStaticType_InitBuiltin()
, especially in Objects/structseq.c.One thing to note is that we add a new "tp_" field:
PyTypeObject.tp_static_builtin_index
. If adding another field to PyTypeObject is too costly then we could conditionally re-purpose some other field (e.g.tp_subclasses
once we don't use it for static types).