summaryrefslogtreecommitdiff
path: root/Include/cpython
diff options
context:
space:
mode:
authorKen Jin <kenjin@python.org>2022-10-10 20:26:08 -0700
committerGitHub <noreply@github.com>2022-10-11 11:26:08 +0800
commitb399115ef18945f7526492225d72a512048ad20d (patch)
treea535c3b234b6eebddee356b9a4df25971f0b89b5 /Include/cpython
parentf871e9a7bb4eb823da481b99052636763ec8e710 (diff)
downloadcpython-git-b399115ef18945f7526492225d72a512048ad20d.tar.gz
gh-95756: Lazily created cached co_* attrs (GH-97791)
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/code.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/Include/cpython/code.h b/Include/cpython/code.h
index 7ce6902255..893ff934d3 100644
--- a/Include/cpython/code.h
+++ b/Include/cpython/code.h
@@ -32,6 +32,13 @@ typedef uint16_t _Py_CODEUNIT;
#define _Py_SET_OPCODE(word, opcode) \
do { ((unsigned char *)&(word))[0] = (opcode); } while (0)
+typedef struct {
+ PyObject *_co_code;
+ PyObject *_co_varnames;
+ PyObject *_co_cellvars;
+ PyObject *_co_freevars;
+} _PyCoCached;
+
// To avoid repeating ourselves in deepfreeze.py, all PyCodeObject members are
// defined in this macro:
#define _PyCode_DEF(SIZE) { \
@@ -90,7 +97,7 @@ typedef uint16_t _Py_CODEUNIT;
PyObject *co_qualname; /* unicode (qualname, for reference) */ \
PyObject *co_linetable; /* bytes object that holds location info */ \
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \
- PyObject *_co_code; /* cached co_code object/attribute */ \
+ _PyCoCached *_co_cached; /* cached co_* attributes */ \
int _co_firsttraceable; /* index of first traceable instruction */ \
char *_co_linearray; /* array of line offsets */ \
/* Scratch space for extra data relating to the code object. \