python byte code 指令释疑
有了解python byte code的没,能解释下?
Miscellaneous opcodes.
PRINT_EXPR()¶
Implements the expression statement for the interactive mode. TOS is removed from the stack and printed. In non-interactive mode, an expression statement is terminated with POP_STACK.PRINT_ITEM()¶
Prints TOS to the file-like object bound to sys.stdout. There is one such instruction for each item in the print statement.PRINT_ITEM_TO()¶
Like PRINT_ITEM, but prints the item second from TOS to the file-like object at TOS. This is used by the extended print statement.PRINT_NEWLINE()¶
Prints a new line on sys.stdout. This is generated as the last operation of a print statement, unless the statement ends with a comma.PRINT_NEWLINE_TO()¶
Like PRINT_NEWLINE, but prints the new line on the file-like object on the TOS. This is used by the extended print statement.BREAK_LOOP()¶
Terminates a loop due to a break statement.CONTINUE_LOOP(target)¶
Continues a loop due to a continue statement. target is the address to jump to (which should be a FOR_ITER instruction).LIST_APPEND(i)¶
Calls list.append(TOS[-i], TOS). Used to implement list comprehensions. While the appended value is popped off, the list object remains on the stack so that it is available for further iterations of the loop.LOAD_LOCALS()¶
Pushes a reference to the locals of the current scope on the stack. This is used in the code for a class definition: After the class body is evaluated, the locals are passed to the class definition.RETURN_VALUE()¶
Returns with TOS to the caller of the function.YIELD_VALUE()¶
Pops TOS and yields it from a generator.IMPORT_STAR()¶
Loads all symbols not starting with '_' directly from the module TOS to the local namespace. The module is popped after loading all names. This opcode implements from module import *.EXEC_STMT()¶
Implements exec TOS2,TOS1,TOS. The compiler fills missing optional parameters with None.POP_BLOCK()¶
Removes one block from the block stack. Per frame, there is a stack of blocks, denoting nested loops, try statements, and such.END_FINALLY()¶
Terminates a finally clause. The interpreter recalls whether the exception has to be re-raised, or whether the function returns, and continues with the outer-next block.BUILD_CLASS()¶
Creates a new class object. TOS is the methods dictionary, TOS1 the tuple of the names of the base classes, and TOS2 the class name.SETUP_WITH(delta)¶
This opcode performs several operations before a with block starts. First, it loads __exit__() from the context manager and pushes it onto the stack for later use by WITH_CLEANUP. Then, __enter__() is called, and a finally block pointing to delta is pushed. Finally, the result of calling the enter method is pushed onto the stack. The next opcode will either ignore it (POP_TOP), or store it in (a) variable(s) (STORE_FAST, STORE_NAME, or UNPACK_SEQUENCE).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论