Skip to content

Commit aa8591e

Browse files
gh-90111: Minor Cleanup for Runtime-Global Objects (gh-100254)
* move _PyRuntime.global_objects.interned to _PyRuntime.cached_objects.interned_strings (and use _Py_CACHED_OBJECT()) * rename _PyRuntime.global_objects to _PyRuntime.static_objects (This also relates to gh-96075.) #90111
1 parent 9663853 commit aa8591e

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Include/internal/pycore_global_objects.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ extern "C" {
2828

2929
struct _Py_cached_objects {
3030
PyObject *str_replace_inf;
31+
32+
PyObject *interned_strings;
3133
};
3234

3335
#define _Py_GLOBAL_OBJECT(NAME) \
34-
_PyRuntime.global_objects.NAME
36+
_PyRuntime.static_objects.NAME
3537
#define _Py_SINGLETON(NAME) \
3638
_Py_GLOBAL_OBJECT(singletons.NAME)
3739

38-
struct _Py_global_objects {
40+
struct _Py_static_objects {
3941
struct {
4042
/* Small integers are preallocated in this array so that they
4143
* can be shared.
@@ -59,8 +61,6 @@ struct _Py_global_objects {
5961
PyHamtNode_Bitmap hamt_bitmap_node_empty;
6062
_PyContextTokenMissing context_token_missing;
6163
} singletons;
62-
63-
PyObject *interned;
6464
};
6565

6666
#define _Py_INTERP_CACHED_OBJECT(interp, NAME) \

Include/internal/pycore_runtime.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ typedef struct pyruntimestate {
163163

164164
/* All the objects that are shared by the runtime's interpreters. */
165165
struct _Py_cached_objects cached_objects;
166-
struct _Py_global_objects global_objects;
166+
struct _Py_static_objects static_objects;
167167

168168
/* The following fields are here to avoid allocation during init.
169169
The data is exposed through _PyRuntimeState pointer fields.

Include/internal/pycore_runtime_init.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extern "C" {
7070
.types = { \
7171
.next_version_tag = 1, \
7272
}, \
73-
.global_objects = { \
73+
.static_objects = { \
7474
.singletons = { \
7575
.small_ints = _Py_small_ints_INIT, \
7676
.bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \

Objects/unicodeobject.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ static inline PyObject* unicode_new_empty(void)
233233
*/
234234
static inline PyObject *get_interned_dict(void)
235235
{
236-
return _PyRuntime.global_objects.interned;
236+
return _Py_CACHED_OBJECT(interned_strings);
237237
}
238238

239239
static inline void set_interned_dict(PyObject *dict)
240240
{
241-
_PyRuntime.global_objects.interned = dict;
241+
_Py_CACHED_OBJECT(interned_strings) = dict;
242242
}
243243

244244
#define _Py_RETURN_UNICODE_EMPTY() \

0 commit comments

Comments
 (0)