Path: blob/main/Include/internal/pycore_global_objects.h
12 views
#ifndef Py_INTERNAL_GLOBAL_OBJECTS_H1#define Py_INTERNAL_GLOBAL_OBJECTS_H2#ifdef __cplusplus3extern "C" {4#endif56#ifndef Py_BUILD_CORE7# error "this header requires Py_BUILD_CORE define"8#endif910#include "pycore_gc.h" // PyGC_Head11#include "pycore_global_strings.h" // struct _Py_global_strings12#include "pycore_hamt.h" // PyHamtNode_Bitmap13#include "pycore_context.h" // _PyContextTokenMissing14#include "pycore_typeobject.h" // pytype_slotdef151617// These would be in pycore_long.h if it weren't for an include cycle.18#define _PY_NSMALLPOSINTS 25719#define _PY_NSMALLNEGINTS 5202122// Only immutable objects should be considered runtime-global.23// All others must be per-interpreter.2425#define _Py_GLOBAL_OBJECT(NAME) \26_PyRuntime.static_objects.NAME27#define _Py_SINGLETON(NAME) \28_Py_GLOBAL_OBJECT(singletons.NAME)2930struct _Py_static_objects {31struct {32/* Small integers are preallocated in this array so that they33* can be shared.34* The integers that are preallocated are those in the range35* -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (exclusive).36*/37PyLongObject small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];3839PyBytesObject bytes_empty;40struct {41PyBytesObject ob;42char eos;43} bytes_characters[256];4445struct _Py_global_strings strings;4647_PyGC_Head_UNUSED _tuple_empty_gc_not_used;48PyTupleObject tuple_empty;4950_PyGC_Head_UNUSED _hamt_bitmap_node_empty_gc_not_used;51PyHamtNode_Bitmap hamt_bitmap_node_empty;52_PyContextTokenMissing context_token_missing;53} singletons;54};5556#define _Py_INTERP_CACHED_OBJECT(interp, NAME) \57(interp)->cached_objects.NAME5859struct _Py_interp_cached_objects {60PyObject *interned_strings;6162/* AST */63PyObject *str_replace_inf;6465/* object.__reduce__ */66PyObject *objreduce;67PyObject *type_slots_pname;68pytype_slotdef *type_slots_ptrs[MAX_EQUIV];6970/* TypeVar and related types */71PyTypeObject *generic_type;72PyTypeObject *typevar_type;73PyTypeObject *typevartuple_type;74PyTypeObject *paramspec_type;75PyTypeObject *paramspecargs_type;76PyTypeObject *paramspeckwargs_type;77};7879#define _Py_INTERP_STATIC_OBJECT(interp, NAME) \80(interp)->static_objects.NAME81#define _Py_INTERP_SINGLETON(interp, NAME) \82_Py_INTERP_STATIC_OBJECT(interp, singletons.NAME)8384struct _Py_interp_static_objects {85struct {86int _not_used;87// hamt_empty is here instead of global because of its weakreflist.88_PyGC_Head_UNUSED _hamt_empty_gc_not_used;89PyHamtObject hamt_empty;90PyBaseExceptionObject last_resort_memory_error;91} singletons;92};939495#ifdef __cplusplus96}97#endif98#endif /* !Py_INTERNAL_GLOBAL_OBJECTS_H */99100101