Skip to content

Commit

Permalink
pythongh-100227: Move the Dict of Interned Strings to PyInterpreterSt…
Browse files Browse the repository at this point in the history
…ate (pythongh-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.

python#100227
  • Loading branch information
ericsnowcurrently authored and warsaw committed Apr 11, 2023
1 parent 88d2e32 commit 94a255e
Show file tree
Hide file tree
Showing 6 changed files with 727 additions and 718 deletions.
9 changes: 2 additions & 7 deletions Include/internal/pycore_global_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion Include/internal/pycore_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
Loading

0 comments on commit 94a255e

Please sign in to comment.