Skip to content

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

Merged
ericsnowcurrently merged 30 commits into
python:mainfrom
ericsnowcurrently:static-builtin-state
Jul 26, 2022
Merged

gh-94673: Add Per-Interpreter Storage for Static Builtin Types#95255
ericsnowcurrently merged 30 commits into
python:mainfrom
ericsnowcurrently:static-builtin-state

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Jul 25, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

This was split out of #94995.

@ericsnowcurrently

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

🤖 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