summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-02-24 12:10:53 (GMT)
committerGitHub <noreply@github.com>2022-02-24 12:10:53 (GMT)
commitae3adbeaedb0536292f4542a0d42063410ae150f (patch)
tree3d78c321bc08baffece9ac73cacafd9a5f67cbb6 /Objects
parent7fce1063b6e5a366f8504e039a8ccdd6944625cd (diff)
downloadcpython-ae3adbeaedb0536292f4542a0d42063410ae150f.zip
cpython-ae3adbeaedb0536292f4542a0d42063410ae150f.tar.gz
cpython-ae3adbeaedb0536292f4542a0d42063410ae150f.tar.bz2
Add (undocumented) _co_quickened attribute for code object. (GH-31552)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/codeobject.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index f8ef1e6..f166204 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -1537,6 +1537,16 @@ code_getfreevars(PyCodeObject *code, void *closure)
return _PyCode_GetFreevars(code);
}
+static PyObject *
+code_getquickened(PyCodeObject *code, void *closure)
+{
+ if (code->co_quickened == NULL) {
+ Py_RETURN_NONE;
+ }
+ return PyBytes_FromStringAndSize((char *)code->co_firstinstr,
+ PyBytes_Size(code->co_code));
+}
+
static PyGetSetDef code_getsetlist[] = {
{"co_lnotab", (getter)code_getlnotab, NULL, NULL},
// The following old names are kept for backward compatibility.
@@ -1544,6 +1554,7 @@ static PyGetSetDef code_getsetlist[] = {
{"co_varnames", (getter)code_getvarnames, NULL, NULL},
{"co_cellvars", (getter)code_getcellvars, NULL, NULL},
{"co_freevars", (getter)code_getfreevars, NULL, NULL},
+ {"_co_quickened", (getter)code_getquickened, NULL, NULL},
{0}
};
@@ -1902,7 +1913,7 @@ _PyCode_ConstantKey(PyObject *op)
return key;
}
-void
+void
_PyStaticCode_Dealloc(PyCodeObject *co)
{
if (co->co_quickened) {
@@ -1921,7 +1932,7 @@ _PyStaticCode_Dealloc(PyCodeObject *co)
}
void
-_PyStaticCode_InternStrings(PyCodeObject *co)
+_PyStaticCode_InternStrings(PyCodeObject *co)
{
int res = intern_strings(co->co_names);
assert(res == 0);