-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 #111459
Conversation
Doesn't this mean we lose the optimization for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
|
|
|
|
gen_close
needs to know whether aRESUME
follows aYIELD_VALUE
which is at except-depth 1, for an important optimization. Currently the compiler stores this information in the oparg ofYIELD_VALUE
, which requiresgen_close
to peek into the bytecode (which is unsafe in the debugger). This PR puts this information in the oparg of theRESUME
, and removes the oparg ofYIELD_VALUE
. The result is simpler and safer code in gen_close.It also removes an anomaly in the bytecode definitions, where we needed to add a meaningless assertion to make the code generator understand that YIELD_VALUE has an oparg even though it doesn't use it.
📚 Documentation preview 📚: https://cpython-previews--111459.org.readthedocs.build/