GH-131238: Core header refactor (GH-131250)

* Moves most structs in pycore_ header files into pycore_structs.h and pycore_runtime_structs.h

* Removes many cross-header dependencies
This commit is contained in:
Mark Shannon 2025-03-17 09:19:04 +00:00 committed by GitHub
parent 3ae67ba97e
commit a1aeec61c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 1481 additions and 1356 deletions

View file

@ -1,6 +1,7 @@
#include "Python.h"
#include "pycore_fileutils.h" // _Py_fstat_noraise()
#include "pycore_initconfig.h"
#include "pycore_pyhash.h" // _Py_HashSecret_t
#include "pycore_pylifecycle.h" // _PyOS_URandomNonblock()
#include "pycore_runtime.h" // _PyRuntime

View file

@ -122,6 +122,7 @@
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include <stdlib.h> // exit()
/* if _PY_SHORT_FLOAT_REPR == 0, then don't even try to compile
the following code */
#if _PY_SHORT_FLOAT_REPR == 1
@ -157,7 +158,7 @@
#endif
// ULong is defined in pycore_dtoa.h.
typedef uint32_t ULong;
typedef int32_t Long;
typedef uint64_t ULLong;

View file

@ -5,6 +5,7 @@
#include "Python.h"
#include "pycore_fileutils.h" // _Py_GetLocaleconvNumeric()
#include "pycore_long.h" // _PyLong_FormatWriter()
#include "pycore_unicodeobject.h" // PyUnicode_MAX_CHAR_VALUE()
#include <locale.h>
/* Raises an exception about an unknown presentation type for this

View file

@ -8,6 +8,7 @@
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
#include "pycore_pylifecycle.h" // _Py_PreInitializeFromConfig()
#include "pycore_pymem.h" // _PyMem_DefaultRawMalloc()
#include "pycore_pyhash.h" // _Py_HashSecret
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_pystats.h" // _Py_StatsOn()
#include "pycore_sysmodule.h" // _PySys_SetIntMaxStrDigits()

View file

@ -18,6 +18,7 @@
#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_STORE_UINTPTR_RELEASE
#include "pycore_pyerrors.h"
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_runtime_structs.h" // _PyCoMonitoringData
/* Uncomment this to dump debugging output when assertions fail */
// #define INSTRUMENT_DEBUG 1

View file

@ -1,6 +1,7 @@
/* PyInterpreterConfig API */
#include "Python.h"
#include "pycore_interp.h" // Py_RTFLAGS
#include "pycore_pylifecycle.h"
#include <stdbool.h>

View file

@ -5,12 +5,15 @@
#include "pycore_frame.h"
#include "pycore_function.h"
#include "pycore_global_objects.h"
#include "pycore_genobject.h" // _PyAsyncGenValueWrapperNew
#include "pycore_compile.h" // _PyCompile_GetUnaryIntrinsicName, etc
#include "pycore_intrinsics.h" // INTRINSIC_PRINT
#include "pycore_pyerrors.h" // _PyErr_SetString()
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_sysmodule.h" // _PySys_GetRequiredAttr()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_typevarobject.h" // _Py_make_typevar()
#include "pycore_unicodeobject.h" // _PyUnicode_FromASCII
/******** Unary functions ********/

View file

@ -1,7 +1,8 @@
/* Python interpreter top-level routines, including init/exit */
#include "Python.h"
#include "pycore_runtime_structs.h"
#include "pycore_unicodeobject.h"
#include "pycore_audit.h" // _PySys_ClearAuditHooks()
#include "pycore_call.h" // _PyObject_CallMethod()
#include "pycore_ceval.h" // _PyEval_FiniGIL()
@ -13,6 +14,7 @@
#include "pycore_freelist.h" // _PyObject_ClearFreeLists()
#include "pycore_floatobject.h" // _PyFloat_InitTypes()
#include "pycore_global_objects_fini_generated.h" // "_PyStaticObjects_CheckRefcnt()
#include "pycore_hamt.h" // _PyHamt_Type
#include "pycore_import.h" // _PyImport_BootstrapImp()
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_list.h" // _PyList_Fini()

View file

@ -2,6 +2,8 @@
/* Thread and interpreter state structures and their interfaces */
#include "Python.h"
#include "pycore_runtime_structs.h"
#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_audit.h" // _Py_AuditHookEntry
#include "pycore_ceval.h"
@ -18,6 +20,7 @@
#include "pycore_pylifecycle.h" // _PyAST_Fini()
#include "pycore_pymem.h" // _PyMem_DebugEnabled()
#include "pycore_pystate.h"
#include "pycore_runtime.h" // _PyRuntime
#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
#include "pycore_stackref.h" // Py_STACKREF_DEBUG
#include "pycore_time.h" // _PyTime_Init()

View file

@ -3,6 +3,7 @@
#include "pycore_frame.h"
#include "pycore_pyerrors.h" // export _Py_UTF8_Edit_Cost()
#include "pycore_runtime.h" // _Py_ID()
#include "pycore_unicodeobject.h" // _PyUnicode_Equal()
#define MAX_CANDIDATE_ITEMS 750
#define MAX_STRING_SIZE 40