Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-135447: Document NOT_TAKEN & POP_ITER bytecode instructions#135803
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Yzi-Li commented Jun 22, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Yzi-Li commented Jun 22, 2025
@Fidget-Spinner I did a PR to fix the issue. I'm not sure if my expression is correct, so could you take a look? Thanks! |
Fidget-Spinner commented Jun 22, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I think there's some misconception happening here, but no worries, I'll explain how to interpret the bytecode. To document a new bytecode, you need to go to this file https://github.com/python/cpython/blob/main/Python/bytecodes.c . Then, find the bytecode definition (for example, Based on this, are you able to infer the behavior of |
Yzi-Li commented Jun 23, 2025
I have seen what you wrote. And I think I am able to express it. But I've been a little busy recently so I might need a couple of days — sorry for the delay. |
Doc/library/dis.rst Outdated
| Create a Template object consuming interpolations and a string from the stack, | ||
| and pushes it onto the stack. | ||
| It consumes ``STACK[-1]``(string) and ``STACK[-2]``(interpolations) and |
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.
Nice, this is pretty close. One small error: it's the other way around, interpolations is STACK[-1], string is STACK[-2]. This is because the bytecode definition file models a stack (LIFO), which means the rightmost element is the top of the stack.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Ken Jin <[email protected]>
Doc/library/dis.rst Outdated
| Do nothing code. Used as a hint to the interpreter that a branch was predicted | ||
| as not taken. |
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.
I forgot what NOT_TAKEN does, but the rest look good. Maybe @iritkatriel knows?
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.
It indeed does nothing. Not sure it's related to prediction though. It think it's to give tracing applications like code coverage a way to distinguish between the taken/not taken branches.
CC @markshannon
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.
pureinst(NOP, (--)){} family(RESUME, 0) ={RESUME_CHECK, }; macro(NOT_TAKEN) =NOP;Can we consider its behavior to be the same as NOP?
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.
Yes its a NOP but I forgot if its a hint or not.
Yzi-Li commented Jul 6, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Sorry, I did some meaningless commits. |
Fidget-Spinner commented Jul 11, 2025
I'm off next week. If no one else gets to it, I'll review the new changes the 2 weeks from now. |
AA-Turner commented Sep 21, 2025
@Fidget-Spinner do you have any further comments/reviews/objections? Would be good to document the 3.14 bytecodes, either in this PR or a different one. A |
AA-Turner commented Sep 28, 2025
I'll merge this, it adds documentation for two missing bytecode instructions for 3.14. Further improvements & other bytecodes can come later. A |
NOT_TAKEN & POP_ITER bytecode instructions519bc47 into python:mainUh oh!
There was an error while loading. Please reload this page.
Thanks @Yzi-Li for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…nstructions (pythonGH-135803) (cherry picked from commit 519bc47) Co-authored-by: Yongzi Li <[email protected]> Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Ken Jin <[email protected]>
GH-139399 is a backport of this pull request to the 3.14 branch. |
…instructions (GH-135803) (#139399) Co-authored-by: Yongzi Li <[email protected]> Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Ken Jin <[email protected]>
Document:
dismodule docs #135447📚 Documentation preview 📚: https://cpython-previews--135803.org.readthedocs.build/