◐ Shell
reader mode source ↗
Skip to content

bpo-46006: Move the interned strings and identifiers to _PyRuntimeState.#30131

Closed
ericsnowcurrently wants to merge 5 commits into
python:mainfrom
ericsnowcurrently:move-interned-to-runtime-state
Closed

bpo-46006: Move the interned strings and identifiers to _PyRuntimeState.#30131
ericsnowcurrently wants to merge 5 commits into
python:mainfrom
ericsnowcurrently:move-interned-to-runtime-state

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Dec 16, 2021

Copy link
Copy Markdown
Member

Currently the interned strings (and strings created for _Py_IDENTIFIER()) are per-interpreter. This is causing some bugs because other objects which may hold a reference to the string are still global. So until we are closer to moving the bulk of the global objects to per-interpreter, the simplest thing is to move the interned strings (and identifiers) to _PyRuntimeState.

https://bugs.python.org/issue46006

@nascheme

nascheme commented Jan 4, 2022

Copy link
Copy Markdown
Member

I didn't review the code but this seems like a good way to fix bpo-46006. We can have more time to figure out how to make them per-interpreter (assuming that's the decision).

@markshannon

Copy link
Copy Markdown
Member

I agree with @nascheme that this is probably the best fix for 3.11a4.
I think longer term we will have to go for statically allocated identifiers.
Any other approach is just too error prone.

Let's hope that we can keep the overhead of immortal objects low enough that we can have parallel sub-interpreters and static global objects.

@vstinner

vstinner commented Jan 5, 2022

Copy link
Copy Markdown
Member

https://bugs.python.org/issue46006 is about interned strings. Fixing this issue doesn't need to share again identifiers between all interpreters. I'm not convinced by the value of moving the structures from PyInterpreterState to _PyRuntimeState.

I propose a different PR which only reverts ea25180 : PR #30422. It only moves the interned variable from PyInterpreterState to unicodeobject.c (static variable). Identifiers are left unchanged.

@vstinner

vstinner commented Jan 6, 2022

Copy link
Copy Markdown
Member

I merged my GH-20085 revert.

@vstinner vstinner closed this Jan 6, 2022
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.

6 participants