Skip to content

GH-100719: Remove the co_nplaincellvars field from code objects. - #100721

Merged
markshannon merged 4 commits into
python:mainfrom
faster-cpython:trim-code-object
Jan 4, 2023
Merged

markshannon merged 4 commits into
python:mainfrom
faster-cpython:trim-code-object

Conversation

@markshannon

@markshannon markshannon commented Jan 3, 2023 •

Copy link
Copy Markdown
Member
Comment thread Objects/typeobject.c
// Look for __class__ in the free vars.
PyTypeObject *type = NULL;
int i = co->co_nlocals + co->co_nplaincellvars;
int i = PyCode_GetFirstFree(co);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Py_ssize_t?

@markshannon markshannon Jan 4, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an int. I'll change PyCode_GetFirstFree.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markshannon why should it be int?

Comment thread Objects/frameobject.c
/* Free vars have not been initialized -- Do that */
PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
int offset = co->co_nlocals + co->co_nplaincellvars;
int offset = PyCode_GetFirstFree(co);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Py_ssize_t?

Comment thread Python/compile.c

if (co->co_nfreevars) {
int i = co->co_nlocals + co->co_nplaincellvars;
int i = PyCode_GetFirstFree(co);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Py_ssize_t?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants