bpo-40521: Per-interpreter interned strings #20085
Conversation
This change requires https://bugs.python.org/issue39465 to be fixed, and also to make the type method cache compatible with subinterpreters. |
d86790c
to
342c3ed
With this PR, tests using subinterpreters like test_ast.test_subinterpreter() does crash since the method cache is built by default, whereas it shares interned strings between multiple interpreters. MCACHE must not be defined to test this PR, or the method cache must be fixed for subinterpreters. |
342c3ed
to
b11a338
I rebased my PR on master. It is still a draft: PR #20058 must be merged first, and then the method cache must be fixed for subinterpreter, before we can consider to merge this PR. |
0bbf371
to
2420a96
2420a96
to
5b46b09
And I pushed a second fix for test_repl:
It's more an enhancement than a fix. Previously, the code also failed. It's just that previously, we didn't check if interned is NULL at exit, whereas my PR adds such assertion. |
5b46b09
to
5aea9de
Make the Unicode dictionary of interned strings compatible with subinterpreters. Remove the INTERN_NAME_STRINGS macro in typeobject.c: names are always now interned (even if EXPERIMENTAL_ISOLATED_SUBINTERPRETERS macro is defined). _PyUnicode_ClearInterned() now uses PyDict_Next() to no longer allocate memory, to ensure that the interned dictionary is cleared.
5aea9de
to
8cb4246
ea25180
into
python:master
Make the Unicode dictionary of interned strings per-interpreter to
make it compatible with subinterpreters.
https://bugs.python.org/issue40521