Skip to content
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

_PyStaticType_InitBuiltin should not exist. #103276

Open
markshannon opened this issue Apr 5, 2023 · 1 comment
Open

_PyStaticType_InitBuiltin should not exist. #103276

markshannon opened this issue Apr 5, 2023 · 1 comment
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@markshannon
Copy link
Member

Part three in an ongoing series...

Following on from #96458 and #101603.

Static, builtin classes must be sharable across interpreters.
Therefore, they should be immortal and idempotent immutable. Ideally they should be immutable, but we can tolerate a bit of initialization as long as it is idempotent and thread-safe.
Therefore _PyStaticType_InitBuiltin should not exist.
We can also free up the _Py_TPFLAGS_STATIC_BUILTIN flag, as we are running low on flags.

AFAICT _PyStaticType_InitBuiltin sets an index for accessing the subclasses dict on the interpreter, and calls PyType_Ready. That's all.
PyType_Ready should be a no op on static builtin classes. (If it isn't, then that's another issue we need to add.)
Setting the subclass index can be done lazily, as many builtin classes are never subclassed.
There is no reason for the index to be distinct from the version tag, so we should use that, and statically initialize it for int, type, etc.

@ericsnowcurrently @kumaraditya303
Any more of these static init/dealloc functions? They should all go.

@markshannon markshannon added the type-bug An unexpected behavior, bug, or error label Apr 5, 2023
@ericsnowcurrently
Copy link
Member

FWIW, everything you've said makes sense. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants