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:
Eric Snow 2023-03-28 12:52:28 -06:00 committed by GitHub
parent 7703def37e
commit ba65a065cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 727 additions and 718 deletions

View file

@ -23,13 +23,6 @@ extern "C" {
// Only immutable objects should be considered runtime-global.
// All others must be per-interpreter.
#define _Py_CACHED_OBJECT(NAME) \
_PyRuntime.cached_objects.NAME
struct _Py_cached_objects {
PyObject *interned_strings;
};
#define _Py_GLOBAL_OBJECT(NAME) \
_PyRuntime.static_objects.NAME
#define _Py_SINGLETON(NAME) \
@ -65,6 +58,8 @@ struct _Py_static_objects {
(interp)->cached_objects.NAME
struct _Py_interp_cached_objects {
PyObject *interned_strings;
/* AST */
PyObject *str_replace_inf;

View file

@ -163,7 +163,6 @@ typedef struct pyruntimestate {
} types;
/* All the objects that are shared by the runtime's interpreters. */
struct _Py_cached_objects cached_objects;
struct _Py_static_objects static_objects;
/* The following fields are here to avoid allocation during init.

View file

@ -59,6 +59,7 @@ struct _Py_unicode_state {
struct _Py_unicode_ids ids;
};
extern void _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p);
extern void _PyUnicode_ClearInterned(PyInterpreterState *interp);

File diff suppressed because it is too large Load diff