-
-
Notifications
You must be signed in to change notification settings - Fork 33k
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
Conversation
@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! |
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 |
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.
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.
pure inst(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.
Sorry, I did some meaningless commits. |
I'm off next week. If no one else gets to it, I'll review the new changes the 2 weeks from now. |
@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 |
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 instructions
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:
dis
module docs #135447📚 Documentation preview 📚: https://cpython-previews--135803.org.readthedocs.build/