Skip to content

Conversation

@iritkatriel
Copy link
Member

@iritkatrieliritkatriel commented Apr 5, 2023

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

Seems reasonable from a fairly quick scan.

There is no change in capability or optimizations, this is just a refactor. Correct?

staticintcfg_to_instr_sequence(cfg_builder*g, instr_sequence*seq);

staticPyCodeObject*
assemble_code_unit(structcompiler_unit*u, PyObject*const_cache,
Copy link
Member

Choose a reason for hiding this comment

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

Is this name still correct? Was it ever?

It seems to do optimization and assembly.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

There used to be just assemble(C) which takes the compiler and and does all the optimization and assembly. I split out assemble_code_unit (which takes just the c->u and not the whole c) and does most of what used to be in assemble(). So the name was always incorrect (assemble() called the optimizer). I think the reason it was done like this is that assemble() gets called from a number of places in the compiler (lambda, class, module, etc). So it was convenient to have one function that does opt+assemble and returns a code object.

We can rename assemble() and assemble_code_unit(). Any suggestions what to call it? something like instr_sequence_to_code_object()?

@markshannonmarkshannon self-requested a review April 11, 2023 10:13
@iritkatrieliritkatriel merged commit 33822d0 into python:mainApr 11, 2023
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Apr 18, 2023
iritkatriel added a commit to iritkatriel/cpython that referenced this pull request Jun 2, 2023
iritkatriel added a commit that referenced this pull request Jun 3, 2023
@iritkatrieliritkatriel deleted the cfg branch July 25, 2023 18:05
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@iritkatriel@markshannon@bedevere-bot