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).
页:
[1]