-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-135447: Document new bytecodes in 3.14
#135803
8000
h1>
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
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
base: main
Are you sure you want to change the base?
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
|
||
.. versionadded:: 3.14 | ||
|
||
|
||
.. opcode:: BUILD_TEMPLATE | ||
|
||
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 <kenjin4096@gmail.com>
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.
Document:
dis
module docs #135447📚 Documentation preview 📚: https://cpython-previews--135803.org.readthedocs.build/