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 14 15 // These would be in pycore_long.h if it weren't for an include cycle. 16 #define _PY_NSMALLPOSINTS 257 17 #define _PY_NSMALLNEGINTS 5 18 19 20 // Only immutable objects should be considered runtime-global. 21 // All others must be per-interpreter. 22 23 #define _Py_GLOBAL_OBJECT(NAME) \ 24 _PyRuntime.global_objects.NAME 25 #define _Py_SINGLETON(NAME) \ 26 _Py_GLOBAL_OBJECT(singletons.NAME) 27 28 struct _Py_global_objects { 29 struct { 30 /* Small integers are preallocated in this array so that they 31 * can be shared. 32 * The integers that are preallocated are those in the range 33 * -_PY_NSMALLNEGINTS (inclusive) to _PY_NSMALLPOSINTS (exclusive). 34 */ 35 PyLongObject small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS]; 36 37 PyBytesObject bytes_empty; 38 struct { 39 PyBytesObject ob; 40 char eos; 41 } bytes_characters[256]; 42 43 struct _Py_global_strings strings; 44 45 _PyGC_Head_UNUSED _tuple_empty_gc_not_used; 46 PyTupleObject tuple_empty; 47 } singletons; 48 }; 49 50 51 #ifdef __cplusplus 52 } 53 #endif 54 #endif /* !Py_INTERNAL_GLOBAL_OBJECTS_H */ 55