Skip to content

Commit ba65a06

Browse files
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. #100227
1 parent 7703def commit ba65a06

File tree

6 files changed

+727
-718
lines changed

6 files changed

+727
-718
lines changed

Include/internal/pycore_global_objects.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ extern "C" {
2323
// Only immutable objects should be considered runtime-global.
2424
// All others must be per-interpreter.
2525

26-
#define _Py_CACHED_OBJECT(NAME) \
27-
_PyRuntime.cached_objects.NAME
28-
29-
struct _Py_cached_objects {
30-
PyObject *interned_strings;
31-
};
32-
3326
#define _Py_GLOBAL_OBJECT(NAME) \
3427
_PyRuntime.static_objects.NAME
3528
#define _Py_SINGLETON(NAME) \
@@ -65,6 +58,8 @@ struct _Py_static_objects {
6558
(interp)->cached_objects.NAME
6659

6760
struct _Py_interp_cached_objects {
61+
PyObject *interned_strings;
62+
6863
/* AST */
6964
PyObject *str_replace_inf;
7065

Include/internal/pycore_runtime.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ typedef struct pyruntimestate {
163163
} types;
164164

165165
/* All the objects that are shared by the runtime's interpreters. */
166-
struct _Py_cached_objects cached_objects;
167166
struct _Py_static_objects static_objects;
168167

169168
/* The following fields are here to avoid allocation during init.

Include/internal/pycore_unicodeobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct _Py_unicode_state {
5959
struct _Py_unicode_ids ids;
6060
};
6161

62+
extern void _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p);
6263
extern void _PyUnicode_ClearInterned(PyInterpreterState *interp);
6364

6465

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy