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

gh-94673: Add Per-Interpreter Storage for Static Builtin Types #95255

Merged
merged 30 commits into from
Jul 26, 2022

Conversation

ericsnowcurrently
Copy link
Member

@ericsnowcurrently ericsnowcurrently commented Jul 25, 2022

This is the last precursor to storing tp_subclasses (and tp_weaklist) on the interpreter state for static builtin types.

Here we add per-type storage on PyInterpreterState, but only for the static builtin types. This involves the following:

  • add `PyInterpreterState.types'
    • move PyInterpreterState.type_cache to it
    • add a num_builtins_initialized field
    • add a builtins field (a static array big enough for all the static builtin types)
  • add _PyStaticType_GetState() to look up a static builtin type's state
  • add PyTypeObject.tp_static_builtin_index (to hold the type's index into PyInterpreterState.types.builtins)

(Adding an extra field to PyTypeObject isn't ideal and I may change it to store the index somewhere else.)

@ericsnowcurrently
Copy link
Member Author

This was split out of #94995.

@ericsnowcurrently
Copy link
Member Author

For now consider PyTypeObject.tp_static_builtin_index a temporary addition. I'd like to drop it once we start storing tp_subclasses on PyInterpreterState for static builtin types. At that point we can use tp_subclasses to store the index.

@ericsnowcurrently
Copy link
Member Author

I'm going to leave tp_static_builtin_index undocumented since it is temporary. If that changes then we'll document it.

@ericsnowcurrently ericsnowcurrently added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 25, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @ericsnowcurrently for commit 9f7775d 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 25, 2022
@ericsnowcurrently ericsnowcurrently merged commit 47e75a0 into python:main Jul 26, 2022
@ericsnowcurrently ericsnowcurrently deleted the static-builtin-state branch July 26, 2022 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants