https://github.com/python/cpython/commit/a6a8c6f86e811f9fcdb577bc1d9b85fbf86c8267
commit: a6a8c6f86e811f9fcdb577bc1d9b85fbf86c8267
branch: main
author: Sam Gross <[email protected]>
committer: colesbury <[email protected]>
date: 2025-01-27T17:14:51Z
summary:
gh-128954: Reorder _PyInterpreterFrame fields for reduced memory usage (#128958)
This reduces the size of _PyInterpreterFrame by 8 bytes on 64-bit
platforms using the free threading build due to alignment requirements.
This allows for slightly more recursive calls into the interpreter (from
C), but `test_call.test_super_deep` still crashes.
files:
M Include/internal/pycore_frame.h
M Lib/test/test_sys.py
diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h
index 14dc91e54298ce..155a6f3ce054a2 100644
--- a/Include/internal/pycore_frame.h
+++ b/Include/internal/pycore_frame.h
@@ -69,11 +69,11 @@ typedef struct _PyInterpreterFrame {
PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on
C stack */
PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if
not on C stack */
_Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to
begin) */
+ _PyStackRef *stackpointer;
#ifdef Py_GIL_DISABLED
/* Index of thread-local bytecode containing instr_ptr. */
int32_t tlbc_index;
#endif
- _PyStackRef *stackpointer;
uint16_t return_offset; /* Only relevant during a function call */
char owner;
#ifdef Py_DEBUG
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index d839893d2c657e..39857445a02255 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -1621,7 +1621,7 @@ def func():
return sys._getframe()
x = func()
if support.Py_GIL_DISABLED:
- INTERPRETER_FRAME = '10PhcP'
+ INTERPRETER_FRAME = '9PihcP'
else:
INTERPRETER_FRAME = '9PhcP'
check(x, size('3PiccPP' + INTERPRETER_FRAME + 'P'))
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]