diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-21-23-18-38.gh-issue-160132.Nj4rQa.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-21-23-18-38.gh-issue-160132.Nj4rQa.rst new file mode 100644 index 00000000000000..156f387f7a6998 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-21-23-18-38.gh-issue-160132.Nj4rQa.rst @@ -0,0 +1,3 @@ +Reduce memory usage during compilation by reordering the fields of the +internal basic block structure to reduce padding. +Patch by Shamil Abdulaev. diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 17489ae5bfb525..9248138ba20ac9 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -47,6 +47,16 @@ typedef struct _PyCfgBasicblock { struct _PyCfgBasicblock *b_list; /* The label of this block if it is a jump target, -1 otherwise */ _PyJumpTargetLabel b_label; + /* Basic block is an exception handler that preserves lasti */ + unsigned b_preserve_lasti : 1; + /* Used by compiler passes to mark whether they have visited a basic block. */ + unsigned b_visited : 1; + /* b_except_handler is used by the cold-detection algorithm to mark exception targets */ + unsigned b_except_handler : 1; + /* b_cold is true if this block is not perf critical (like an exception handler) */ + unsigned b_cold : 1; + /* b_warm is used by the cold-detection algorithm to mark blocks which are definitely not cold */ + unsigned b_warm : 1; /* Exception stack at start of block, used by assembler to create the exception handling table */ struct _PyCfgExceptStack *b_exceptstack; /* pointer to an array of instructions, initially NULL */ @@ -64,16 +74,6 @@ typedef struct _PyCfgBasicblock { int b_predecessors; /* depth of stack upon entry of block, computed by stackdepth() */ int b_startdepth; - /* Basic block is an exception handler that preserves lasti */ - unsigned b_preserve_lasti : 1; - /* Used by compiler passes to mark whether they have visited a basic block. */ - unsigned b_visited : 1; - /* b_except_handler is used by the cold-detection algorithm to mark exception targets */ - unsigned b_except_handler : 1; - /* b_cold is true if this block is not perf critical (like an exception handler) */ - unsigned b_cold : 1; - /* b_warm is used by the cold-detection algorithm to mark blocks which are definitely not cold */ - unsigned b_warm : 1; } basicblock;