]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-90111: Minor Cleanup for Runtime-Global Objects (gh-100254)
authorEric Snow <ericsnowcurrently@gmail.com>
Wed, 14 Dec 2022 18:53:57 +0000 (11:53 -0700)
committerGitHub <noreply@github.com>
Wed, 14 Dec 2022 18:53:57 +0000 (11:53 -0700)
* 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.)

https://github.com/python/cpython/issues/90111

Include/internal/pycore_global_objects.h
Include/internal/pycore_runtime.h
Include/internal/pycore_runtime_init.h
Objects/unicodeobject.c

index 80f6bb2c8a7c16bde4fda2cfb3bd2c67f1916fbf..d0461fa7e82e8b42b0e47683187e07ba75fc1a63 100644 (file)
@@ -28,14 +28,16 @@ extern "C" {
 
 struct _Py_cached_objects {
     PyObject *str_replace_inf;
+
+    PyObject *interned_strings;
 };
 
 #define _Py_GLOBAL_OBJECT(NAME) \
-    _PyRuntime.global_objects.NAME
+    _PyRuntime.static_objects.NAME
 #define _Py_SINGLETON(NAME) \
     _Py_GLOBAL_OBJECT(singletons.NAME)
 
-struct _Py_global_objects {
+struct _Py_static_objects {
     struct {
         /* Small integers are preallocated in this array so that they
          * can be shared.
@@ -59,8 +61,6 @@ struct _Py_global_objects {
         PyHamtNode_Bitmap hamt_bitmap_node_empty;
         _PyContextTokenMissing context_token_missing;
     } singletons;
-
-    PyObject *interned;
 };
 
 #define _Py_INTERP_CACHED_OBJECT(interp, NAME) \
index 92ed45956c99b3298e775a769ccd2a3eddb85c66..d100e836c7d15386ee29666d2353a0d37a33c252 100644 (file)
@@ -163,7 +163,7 @@ typedef struct pyruntimestate {
 
     /* All the objects that are shared by the runtime's interpreters. */
     struct _Py_cached_objects cached_objects;
-    struct _Py_global_objects global_objects;
+    struct _Py_static_objects static_objects;
 
     /* The following fields are here to avoid allocation during init.
        The data is exposed through _PyRuntimeState pointer fields.
index 1431096e2d24bafe49e490e42f4978116fb776d4..6342a28f4df911c6a689b1233b80abf0243c25a1 100644 (file)
@@ -70,7 +70,7 @@ extern "C" {
         .types = { \
             .next_version_tag = 1, \
         }, \
-        .global_objects = { \
+        .static_objects = { \
             .singletons = { \
                 .small_ints = _Py_small_ints_INIT, \
                 .bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \
index b721ccd805edf13566b090531c84381e6bf99395..f0c7aa7707fdb57b3d702776d079e81742d5e1a9 100644 (file)
@@ -233,12 +233,12 @@ static inline PyObject* unicode_new_empty(void)
 */
 static inline PyObject *get_interned_dict(void)
 {
-    return _PyRuntime.global_objects.interned;
+    return _Py_CACHED_OBJECT(interned_strings);
 }
 
 static inline void set_interned_dict(PyObject *dict)
 {
-    _PyRuntime.global_objects.interned = dict;
+    _Py_CACHED_OBJECT(interned_strings) = dict;
 }
 
 #define _Py_RETURN_UNICODE_EMPTY()   \