mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-100227: Move the Dict of Interned Strings to PyInterpreterState (gh-102339)
We can revisit the options for keeping it global later, if desired. For now the approach seems quite complex, so we've gone with the simpler isolation solution in the meantime. https://github.com/python/cpython/issues/100227
This commit is contained in:
parent
7703def37e
commit
ba65a065cf
6 changed files with 727 additions and 718 deletions
|
@ -354,14 +354,14 @@ def generate_static_strings_initializer(identifiers, strings):
|
|||
printer.write(before)
|
||||
printer.write(START)
|
||||
printer.write("static inline void")
|
||||
with printer.block("_PyUnicode_InitStaticStrings(void)"):
|
||||
with printer.block("_PyUnicode_InitStaticStrings(PyInterpreterState *interp)"):
|
||||
printer.write(f'PyObject *string;')
|
||||
for i in sorted(identifiers):
|
||||
# This use of _Py_ID() is ignored by iter_global_strings()
|
||||
# since iter_files() ignores .h files.
|
||||
printer.write(f'string = &_Py_ID({i});')
|
||||
printer.write(f'assert(_PyUnicode_CheckConsistency(string, 1));')
|
||||
printer.write(f'PyUnicode_InternInPlace(&string);')
|
||||
printer.write(f'_PyUnicode_InternInPlace(interp, &string);')
|
||||
# XXX What about "strings"?
|
||||
printer.write(END)
|
||||
printer.write(after)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue