FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-46841: Add (undocumented) _co_quickened attribute for code object. by markshannon · Pull Request #31552 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 13 additions & 2 deletions Objects/codeobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1537,13 +1537,24 @@ 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.
{"co_nlocals", (getter)code_getnlocals, NULL, NULL},
{"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}
};

Expand Down Expand Up @@ -1902,7 +1913,7 @@ _PyCode_ConstantKey(PyObject *op)
return key;
}

void
void
_PyStaticCode_Dealloc(PyCodeObject *co)
{
if (co->co_quickened) {
Expand All @@ -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);
Expand Down

Back | FazBrowse Home | New Git URL