(root)/
Python-3.12.0/
Include/
internal/
pycore_global_objects.h
       1  #ifndef Py_INTERNAL_GLOBAL_OBJECTS_H
       2  #define Py_INTERNAL_GLOBAL_OBJECTS_H
       3  #ifdef __cplusplus
       4  extern "C" {
       5  #endif
       6  
       7  #ifndef Py_BUILD_CORE
       8  #  error "this header requires Py_BUILD_CORE define"
       9  #endif
      10  
      11  #include "pycore_gc.h"              // PyGC_Head
      12  #include "pycore_global_strings.h"  // struct _Py_global_strings
      13  #include "pycore_hamt.h"            // PyHamtNode_Bitmap
      14  #include "pycore_context.h"         // _PyContextTokenMissing
      15  #include "pycore_typeobject.h"      // pytype_slotdef
      16  
      17  
      18  // These would be in pycore_long.h if it weren't for an include cycle.
      19  #define _PY_NSMALLPOSINTS           257
      20  #define _PY_NSMALLNEGINTS           5
      21  
      22  
      23  // Only immutable objects should be considered runtime-global.
      24  // All others must be per-interpreter.
      25  
      26  #define _Py_GLOBAL_OBJECT(NAME) \
      27      _PyRuntime.static_objects.NAME
      28  #define _Py_SINGLETON(NAME) \
      29      _Py_GLOBAL_OBJECT(singletons.NAME)
      30  
      31  struct _Py_static_objects {
      32      struct {
      33          /* Small integers are preallocated in this array so that they
      34           * can be shared.
      35           * The integers that are preallocated are those in the range
      36           * -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (exclusive).
      37           */
      38          PyLongObject small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];
      39  
      40          PyBytesObject bytes_empty;
      41          struct {
      42              PyBytesObject ob;
      43              char eos;
      44          } bytes_characters[256];
      45  
      46          struct _Py_global_strings strings;
      47  
      48          _PyGC_Head_UNUSED _tuple_empty_gc_not_used;
      49          PyTupleObject tuple_empty;
      50  
      51          _PyGC_Head_UNUSED _hamt_bitmap_node_empty_gc_not_used;
      52          PyHamtNode_Bitmap hamt_bitmap_node_empty;
      53          _PyContextTokenMissing context_token_missing;
      54      } singletons;
      55  };
      56  
      57  #define _Py_INTERP_CACHED_OBJECT(interp, NAME) \
      58      (interp)->cached_objects.NAME
      59  
      60  struct _Py_interp_cached_objects {
      61      PyObject *interned_strings;
      62  
      63      /* AST */
      64      PyObject *str_replace_inf;
      65  
      66      /* object.__reduce__ */
      67      PyObject *objreduce;
      68      PyObject *type_slots_pname;
      69      pytype_slotdef *type_slots_ptrs[MAX_EQUIV];
      70  
      71      /* TypeVar and related types */
      72      PyTypeObject *generic_type;
      73      PyTypeObject *typevar_type;
      74      PyTypeObject *typevartuple_type;
      75      PyTypeObject *paramspec_type;
      76      PyTypeObject *paramspecargs_type;
      77      PyTypeObject *paramspeckwargs_type;
      78  };
      79  
      80  #define _Py_INTERP_STATIC_OBJECT(interp, NAME) \
      81      (interp)->static_objects.NAME
      82  #define _Py_INTERP_SINGLETON(interp, NAME) \
      83      _Py_INTERP_STATIC_OBJECT(interp, singletons.NAME)
      84  
      85  struct _Py_interp_static_objects {
      86      struct {
      87          int _not_used;
      88          // hamt_empty is here instead of global because of its weakreflist.
      89          _PyGC_Head_UNUSED _hamt_empty_gc_not_used;
      90          PyHamtObject hamt_empty;
      91          PyBaseExceptionObject last_resort_memory_error;
      92      } singletons;
      93  };
      94  
      95  
      96  #ifdef __cplusplus
      97  }
      98  #endif
      99  #endif /* !Py_INTERNAL_GLOBAL_OBJECTS_H */