Skip to content

Commit e8b17e1

Browse files
markshannonasvetlov
authored andcommitted
Add (undocumented) _co_quickened attribute for code object. (GH-31552)
1 parent 738507d commit e8b17e1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Objects/codeobject.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -1537,13 +1537,24 @@ code_getfreevars(PyCodeObject *code, void *closure)
15371537
return _PyCode_GetFreevars(code);
15381538
}
15391539

1540+
static PyObject *
1541+
code_getquickened(PyCodeObject *code, void *closure)
1542+
{
1543+
if (code->co_quickened == NULL) {
1544+
Py_RETURN_NONE;
1545+
}
1546+
return PyBytes_FromStringAndSize((char *)code->co_firstinstr,
1547+
PyBytes_Size(code->co_code));
1548+
}
1549+
15401550
static PyGetSetDef code_getsetlist[] = {
15411551
{"co_lnotab", (getter)code_getlnotab, NULL, NULL},
15421552
// The following old names are kept for backward compatibility.
15431553
{"co_nlocals", (getter)code_getnlocals, NULL, NULL},
15441554
{"co_varnames", (getter)code_getvarnames, NULL, NULL},
15451555
{"co_cellvars", (getter)code_getcellvars, NULL, NULL},
15461556
{"co_freevars", (getter)code_getfreevars, NULL, NULL},
1557+
{"_co_quickened", (getter)code_getquickened, NULL, NULL},
15471558
{0}
15481559
};
15491560

@@ -1902,7 +1913,7 @@ _PyCode_ConstantKey(PyObject *op)
19021913
return key;
19031914
}
19041915

1905-
void
1916+
void
19061917
_PyStaticCode_Dealloc(PyCodeObject *co)
19071918
{
19081919
if (co->co_quickened) {
@@ -1921,7 +1932,7 @@ _PyStaticCode_Dealloc(PyCodeObject *co)
19211932
}
19221933

19231934
void
1924-
_PyStaticCode_InternStrings(PyCodeObject *co)
1935+
_PyStaticCode_InternStrings(PyCodeObject *co)
19251936
{
19261937
int res = intern_strings(co->co_names);
19271938
assert(res == 0);

0 commit comments

Comments
 (0)