mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-100720: refactor calculation of number of frame slots for a code object into the new function _PyFrame_NumSlotsForCodeObject (#100722)
This commit is contained in:
parent
5fb1c08e15
commit
c31e356a10
5 changed files with 15 additions and 4 deletions
|
@ -769,7 +769,7 @@ gen_sizeof(PyGenObject *gen, PyObject *Py_UNUSED(ignored))
|
|||
Py_ssize_t res;
|
||||
res = offsetof(PyGenObject, gi_iframe) + offsetof(_PyInterpreterFrame, localsplus);
|
||||
PyCodeObject *code = gen->gi_code;
|
||||
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
|
||||
res += _PyFrame_NumSlotsForCodeObject(code) * sizeof(PyObject *);
|
||||
return PyLong_FromSsize_t(res);
|
||||
}
|
||||
|
||||
|
@ -850,7 +850,7 @@ static PyObject *
|
|||
make_gen(PyTypeObject *type, PyFunctionObject *func)
|
||||
{
|
||||
PyCodeObject *code = (PyCodeObject *)func->func_code;
|
||||
int slots = code->co_nlocalsplus + code->co_stacksize;
|
||||
int slots = _PyFrame_NumSlotsForCodeObject(code);
|
||||
PyGenObject *gen = PyObject_GC_NewVar(PyGenObject, type, slots);
|
||||
if (gen == NULL) {
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue