The file layout has not changed since Python 3.11, but every release numbers its instructions differently, so the magic number decides which column of the table below applies. A disassembler has to pick its table from the magic number before it can read a single instruction.
The numbers for 3.12, 3.13 and 3.14 are from each release’s own opcode
module. Those for 3.11 and 3.15 are from CPython’s tagged source. Only instructions
that a .pyc file can hold are listed: pseudo-instructions, specialised
forms and INSTRUMENTED_* forms are left out.
Encoding
co_code is a sequence of 16-bit code units, each one byte of opcode and
one byte of argument. Every instruction occupies one code unit, plus any
inline cache units after it. An instruction with no
argument still has the argument byte; it is zero, and it is ignored.
EXTENDED_ARG widens an argument. It goes before the instruction, and its argument becomes the higher byte: up to three prefixes give the following instruction a 32-bit argument.
In 3.11, an opcode of 90 or more takes an argument. From 3.12 the set of opcodes with
arguments is listed by opcode.hasarg, and from 3.13 the threshold means
nothing because the instructions are renumbered.
Inline caches
From Python 3.11, some instructions are followed by a fixed number of 16-bit cache
entries. The interpreter fills them in while the program runs, to specialise the
instruction. In a file they are all zero. They are part of the instruction that precedes
them: dis hides them unless asked, as CACHE instructions. A
reader must step over them.
The number of cache entries, in code units, depends on the instruction and on the release.
| Instruction | 3.11 | 3.12 | 3.13 | 3.14 | 3.15 |
|---|---|---|---|---|---|
BINARY_OP | 1 | 1 | 1 | 5 | 5 |
BINARY_SUBSCR | 4 | 1 | 1 | – | – |
CALL | 4 | 3 | 3 | 3 | 3 |
CALL_FUNCTION_EX | – | – | – | – | 1 |
CALL_KW | – | – | – | 3 | 3 |
COMPARE_OP | 2 | 1 | 1 | 1 | 1 |
CONTAINS_OP | – | – | 1 | 1 | 1 |
FOR_ITER | – | 1 | 1 | 1 | 1 |
GET_ITER | – | – | – | – | 1 |
JUMP_BACKWARD | – | – | 1 | 1 | 1 |
LOAD_ATTR | 4 | 9 | 9 | 9 | 9 |
LOAD_GLOBAL | 5 | 4 | 4 | 4 | 4 |
LOAD_METHOD | 10 | – | – | – | – |
LOAD_SUPER_ATTR | – | 1 | 1 | 1 | 1 |
POP_JUMP_IF_FALSE | – | – | 1 | 1 | 1 |
POP_JUMP_IF_NONE | – | – | 1 | 1 | 1 |
POP_JUMP_IF_NOT_NONE | – | – | 1 | 1 | 1 |
POP_JUMP_IF_TRUE | – | – | 1 | 1 | 1 |
PRECALL | 1 | – | – | – | – |
RESUME | – | – | – | – | 1 |
SEND | – | 1 | 1 | 1 | 1 |
STORE_ATTR | 4 | 4 | 4 | 4 | 4 |
STORE_SUBSCR | 1 | 1 | 1 | 1 | 1 |
TO_BOOL | – | – | 3 | 3 | 3 |
UNPACK_SEQUENCE | 1 | 1 | 1 | 1 | 1 |
PRECALL and LOAD_METHOD exist only in 3.11.
Jump arguments
A jump’s argument counts 16-bit code units, not bytes, and is relative to the point just after the instruction, past its inline caches. In bytes:
target = offset + 2 + 2 × caches ± 2 × argument
The sign is minus for JUMP_BACKWARD,
JUMP_BACKWARD_NO_INTERRUPT, the four POP_JUMP_BACKWARD_IF_*
instructions of 3.11, and END_ASYNC_FOR from 3.14. It is plus for every
other jump.
END_ASYNC_FOR does not really jump. From 3.14 its argument is a pretend
backward jump, used only so that branch monitoring knows where the loop began.
Every instruction
A number in a column is the opcode in that release; – means the release does not have
it. The argument, where one is used, is called arg.
Local slot numbers index co_localsplusnames; a name index goes into
co_names and a constant index into co_consts.
| Name | 3.11 | 3.12 | 3.13 | 3.14 | 3.15 | Meaning |
|---|---|---|---|---|---|---|
ASYNC_GEN_WRAP | 87 | – | – | – | – | Wraps the top of the stack in an async generator wrapper, for yield in an async generator |
BEFORE_ASYNC_WITH | 52 | 52 | 1 | – | – | Takes __aenter__ and __aexit__ from the top; pushes __aexit__, then the result of calling __aenter__() |
BEFORE_WITH | 53 | 53 | 2 | – | – | Pushes the context manager’s __exit__, calls __enter__(), pushes its result |
BINARY_OP | 122 | 122 | 45 | 44 | 42 | Pops two values, pushes the result. arg is the operator |
BINARY_SLICE | – | 26 | 4 | 1 | 1 | Pops end, start and container; pushes container[start:end] |
BINARY_SUBSCR | 25 | 25 | 5 | – | – | Pops key and container; pushes container[key]. Replaced by BINARY_OP in 3.14 |
BUILD_CONST_KEY_MAP | 156 | 156 | 46 | – | – | Pops a tuple of keys, then arg values; pushes a dictionary |
BUILD_INTERPOLATION | – | – | – | 45 | 43 | Pops a value, its source text and an optional format spec; pushes an Interpolation. arg bit 0 means a spec is present; arg >> 2 is the conversion (0 none, 1 !s, 2 !r, 3 !a) |
BUILD_LIST | 103 | 103 | 47 | 46 | 44 | Pops arg items, pushes a list |
BUILD_MAP | 105 | 105 | 48 | 47 | 45 | Pops 2 × arg items, pushes a dictionary of arg entries |
BUILD_SET | 104 | 104 | 49 | 48 | 46 | Pops arg items, pushes a set |
BUILD_SLICE | 133 | 133 | 50 | 49 | 47 | arg is 2 or 3. Pops start and end, and step if 3; pushes a slice |
BUILD_STRING | 157 | 157 | 51 | 50 | 48 | Pops arg strings and pushes them joined |
BUILD_TEMPLATE | – | – | – | 2 | 2 | Pops the interpolations and strings of a template string; pushes a Template |
BUILD_TUPLE | 102 | 102 | 52 | 51 | 49 | Pops arg items, pushes a tuple |
CACHE | 0 | 0 | 0 | 0 | 0 | Not a real instruction. Opcode 0 is the value of a zeroed inline cache entry |
CALL | 171 | 171 | 53 | 52 | 50 | Pops the callable, self or NULL and arg arguments; pushes the result. Which of the two sits lower changed in 3.13. In 3.11 and 3.12, KW_NAMES names the last arguments |
CALL_FUNCTION_EX | 142 | 142 | 54 | 4 | 4 | Calls with an iterable of positional arguments and a keyword mapping. In 3.11 to 3.13, arg bit 0 says the mapping is present. From 3.14 it has no argument and the mapping is always there |
CALL_INTRINSIC_1 | – | 173 | 55 | 53 | 51 | Replaces the top of the stack with the result of an intrinsic selected by arg |
CALL_INTRINSIC_2 | – | 174 | 56 | 54 | 52 | Pops two values and pushes the result of an intrinsic selected by arg |
CALL_KW | – | – | 57 | 55 | 53 | Like CALL, with a tuple of keyword names on top of the stack. arg counts positional and named arguments |
CHECK_EG_MATCH | 37 | 37 | 6 | 5 | 5 | For except*: splits the exception group below the top by the type on top; pushes the rest and the match |
CHECK_EXC_MATCH | 36 | 36 | 7 | 6 | 6 | Pops the type on top; pushes whether the exception below matches it |
CLEANUP_THROW | – | 55 | 8 | 7 | 7 | If the top is StopIteration, pops three values and pushes its value; otherwise re-raises it |
COMPARE_OP | 107 | 107 | 58 | 56 | 54 | Pops two values, pushes the comparison. See comparison operators for the argument |
CONTAINS_OP | 118 | 118 | 59 | 57 | 55 | Pops two values, pushes in, or not in if arg is 1 |
CONVERT_VALUE | – | – | 60 | 58 | 56 | Pops a value, pushes str (arg 1), repr (2) or ascii (3) of it |
COPY | 120 | 120 | 61 | 59 | 57 | Pushes a copy of the item arg places down, counting the top as 1 |
COPY_FREE_VARS | 149 | 149 | 62 | 60 | 58 | Copies arg free variables from the closure into the frame |
DELETE_ATTR | 96 | 96 | 63 | 61 | 59 | Pops an object; del obj.name. arg is a name index |
DELETE_DEREF | 139 | 139 | 64 | 62 | 60 | Empties the cell in slot arg |
DELETE_FAST | 126 | 126 | 65 | 63 | 61 | Deletes the local in slot arg |
DELETE_GLOBAL | 98 | 98 | 66 | 64 | 62 | Deletes a global. arg is a name index |
DELETE_NAME | 91 | 91 | 67 | 65 | 63 | Deletes a name. arg is a name index |
DELETE_SUBSCR | 61 | 61 | 9 | 8 | 8 | Pops key and container; del container[key] |
DICT_MERGE | 164 | 164 | 68 | 66 | 64 | Like DICT_UPDATE, but raises an error on a duplicate key |
DICT_UPDATE | 165 | 165 | 69 | 67 | 65 | Pops a mapping and adds it to the dictionary arg places down |
END_ASYNC_FOR | 54 | 54 | 10 | 68 | 66 | Ends an async for: pops the iterable and the exception; re-raises it unless it is StopAsyncIteration |
END_FOR | – | 4 | 11 | 9 | 9 | Cleans up at the end of a loop. Pops two items in 3.12, one from 3.13 |
END_SEND | – | 5 | 12 | 10 | 10 | Removes the item below the top, when a generator exits |
ENTER_EXECUTOR | – | – | 70 | 255 | 254 | Only exists at run time: hands over to code made by the optimiser. Not expected in a file |
EXIT_INIT_CHECK | – | – | 13 | 11 | 11 | Pops the value __init__ returned and raises TypeError unless it is None. Used by the interpreter internally |
EXTENDED_ARG | 144 | 144 | 71 | 69 | 67 | Gives the next instruction’s argument more high bits |
FORMAT_SIMPLE | – | – | 14 | 12 | 12 | Pops a value, pushes value.__format__("") |
FORMAT_VALUE | 155 | 155 | – | – | – | f-string formatting. arg bits 0–1 pick the conversion (0 none, 1 str, 2 repr, 3 ascii); bit 2 means a format spec is on the stack |
FORMAT_WITH_SPEC | – | – | 15 | 13 | 13 | Pops a spec and a value, pushes value.__format__(spec) |
FOR_ITER | 93 | 93 | 72 | 70 | 68 | Calls __next__() on the iterator on top; pushes the value, or jumps forward by arg when exhausted. In 3.11 the iterator is popped on exhaustion; from 3.12 it stays |
GET_AITER | 50 | 50 | 16 | 14 | 14 | Replaces the top with __aiter__() of it |
GET_ANEXT | 51 | 51 | 18 | 15 | 15 | Pushes an awaitable of __anext__() of the top |
GET_AWAITABLE | 131 | 131 | 73 | 71 | 69 | Replaces the top with an awaitable. arg is 1 after __aenter__, 2 after __aexit__, else 0 |
GET_ITER | 68 | 68 | 19 | 16 | 70 | Replaces the top with iter() of it. In 3.15 it takes an argument and has merged with GET_YIELD_FROM_ITER |
GET_LEN | 30 | 30 | 20 | 18 | 16 | Pushes len() of the top |
GET_YIELD_FROM_ITER | 69 | 69 | 21 | 19 | – | Leaves a generator or coroutine on top unchanged; replaces anything else with iter() of it |
IMPORT_FROM | 109 | 109 | 74 | 72 | 71 | Pushes an attribute of the module on top. arg is a name index |
IMPORT_NAME | 108 | 108 | 75 | 73 | 72 | Pops level and fromlist; pushes the imported module. arg is a name index, except in 3.15, where the name index is arg >> 2 and the low two bits carry lazy-import settings |
IMPORT_STAR | 84 | – | – | – | – | Pops a module and loads its public names into the local namespace |
INTERPRETER_EXIT | – | 3 | 22 | 20 | 18 | Leaves the interpreter loop. Used only by the interpreter’s internal frames |
IS_OP | 117 | 117 | 76 | 74 | 73 | Pops two values, pushes is, or is not if arg is 1 |
JUMP_BACKWARD | 140 | 140 | 77 | 75 | 74 | Jumps back by arg and checks for interrupts |
JUMP_BACKWARD_NO_INTERRUPT | 134 | 134 | 78 | 76 | 75 | Jumps back by arg without checking for interrupts |
JUMP_FORWARD | 110 | 110 | 79 | 77 | 76 | Jumps forward by arg |
JUMP_IF_FALSE_OR_POP | 111 | – | – | – | – | If the top is false, jumps forward by arg and keeps it; otherwise pops it |
JUMP_IF_TRUE_OR_POP | 112 | – | – | – | – | If the top is true, jumps forward by arg and keeps it; otherwise pops it |
KW_NAMES | 172 | 172 | – | – | – | Prefix to CALL: arg is the constant index of a tuple of keyword names for that call |
LIST_APPEND | 145 | 145 | 80 | 78 | 77 | Pops an item and appends it to the list arg places down |
LIST_EXTEND | 162 | 162 | 81 | 79 | 78 | Pops an iterable and extends the list arg places down |
LIST_TO_TUPLE | 82 | – | – | – | – | Pops a list, pushes a tuple of the same items |
LOAD_ASSERTION_ERROR | 74 | 74 | 23 | – | – | Pushes AssertionError |
LOAD_ATTR | 106 | 106 | 82 | 80 | 79 | Replaces the top with an attribute of it. In 3.11, arg is a name index. From 3.12 the name index is arg >> 1, and bit 0 asks for a method load, pushing the method and self or NULL for CALL |
LOAD_BUILD_CLASS | 71 | 71 | 24 | 21 | 19 | Pushes builtins.__build_class__() |
LOAD_CLASSDEREF | 148 | – | – | – | – | Like LOAD_DEREF, but checks the locals dictionary first. Used in class bodies |
LOAD_CLOSURE | 136 | 136 | – | – | – | Pushes the cell in slot arg. A pseudo-instruction from 3.13, when it is compiled to LOAD_FAST |
LOAD_COMMON_CONSTANT | – | – | – | 81 | 80 | Pushes a constant built into the interpreter, selected by arg |
LOAD_CONST | 100 | 100 | 83 | 82 | 81 | Pushes a constant. arg is a constant index |
LOAD_DEREF | 137 | 137 | 84 | 83 | 82 | Pushes the object in the cell in slot arg |
LOAD_FAST | 124 | 124 | 85 | 84 | 83 | Pushes the local in slot arg. From 3.12 only when it is known to be set |
LOAD_FAST_AND_CLEAR | – | 143 | 86 | 85 | 84 | Pushes the local in slot arg, or NULL, and clears it |
LOAD_FAST_BORROW | – | – | – | 86 | 85 | Pushes a borrowed reference to the local in slot arg |
LOAD_FAST_BORROW_LOAD_FAST_BORROW | – | – | – | 87 | 86 | Pushes borrowed references to two locals: slots arg >> 4 and arg & 15 |
LOAD_FAST_CHECK | – | 127 | 87 | 88 | 87 | Pushes the local in slot arg, or raises UnboundLocalError |
LOAD_FAST_LOAD_FAST | – | – | 88 | 89 | 88 | Pushes two locals: slots arg >> 4 and arg & 15 |
LOAD_FROM_DICT_OR_DEREF | – | 176 | 89 | 90 | 89 | Pops a mapping and looks up the name of slot arg in it; falls back to the cell |
LOAD_FROM_DICT_OR_GLOBALS | – | 175 | 90 | 91 | 90 | Pops a mapping and looks up a name in it, then in globals and builtins. arg is a name index |
LOAD_GLOBAL | 116 | 116 | 91 | 92 | 91 | Pushes a global. The name index is arg >> 1; if bit 0 is set, a NULL is also pushed for a call |
LOAD_LOCALS | – | 87 | 25 | 22 | 20 | Pushes the locals dictionary |
LOAD_METHOD | 160 | – | – | – | – | Pops an object; pushes the unbound method and the object, or NULL and the attribute. arg is a name index |
LOAD_NAME | 101 | 101 | 92 | 93 | 92 | Pushes a name found in locals, globals or builtins. arg is a name index |
LOAD_SMALL_INT | – | – | – | 94 | 93 | Pushes the integer arg, from 0 to 255 |
LOAD_SPECIAL | – | – | – | 95 | 94 | Looks up a special method on the top item, selected by arg |
LOAD_SUPER_ATTR | – | 141 | 93 | 96 | 95 | Pops self, the class and super; loads an attribute. The name index is arg >> 2; bit 0 asks for a method load; bit 1 marks the two-argument super |
MAKE_CELL | 135 | 135 | 94 | 97 | 96 | Makes a new cell in slot arg, holding the slot’s value if it has one |
MAKE_FUNCTION | 132 | 132 | 26 | 23 | 21 | Pushes a function made from the code object on top. In 3.11 and 3.12, arg holds flags for extra items on the stack. From 3.13 it has no argument and SET_FUNCTION_ATTRIBUTE does that job |
MAP_ADD | 147 | 147 | 95 | 98 | 97 | Pops a value and key, stores them in the dictionary arg places down |
MATCH_CLASS | 152 | 152 | 96 | 99 | 98 | Pops the keyword names, class and subject; pushes a tuple of attributes, or None. arg is the number of positional sub-patterns |
MATCH_KEYS | 33 | 33 | 27 | 24 | 22 | The top is a tuple of keys, the item below a mapping. Pushes a tuple of the values, or None |
MATCH_MAPPING | 31 | 31 | 28 | 25 | 23 | Pushes whether the top is a mapping |
MATCH_SEQUENCE | 32 | 32 | 29 | 26 | 24 | Pushes whether the top is a sequence and not text or bytes |
NOP | 9 | 9 | 30 | 27 | 25 | Does nothing |
NOT_TAKEN | – | – | – | 28 | 26 | Does nothing. Marks the fall-through side of a branch for monitoring |
POP_EXCEPT | 89 | 89 | 31 | 29 | 27 | Pops a value and uses it to restore the exception state |
POP_ITER | – | – | – | 30 | 28 | Removes the iterator on top |
POP_JUMP_BACKWARD_IF_FALSE | 175 | – | – | – | – | Pops the top; if false, jumps back by arg |
POP_JUMP_BACKWARD_IF_NONE | 174 | – | – | – | – | Pops the top; if None, jumps back by arg |
POP_JUMP_BACKWARD_IF_NOT_NONE | 173 | – | – | – | – | Pops the top; if not None, jumps back by arg |
POP_JUMP_BACKWARD_IF_TRUE | 176 | – | – | – | – | Pops the top; if true, jumps back by arg |
POP_JUMP_FORWARD_IF_FALSE | 114 | – | – | – | – | Pops the top; if false, jumps forward by arg |
POP_JUMP_FORWARD_IF_NONE | 129 | – | – | – | – | Pops the top; if None, jumps forward by arg |
POP_JUMP_FORWARD_IF_NOT_NONE | 128 | – | – | – | – | Pops the top; if not None, jumps forward by arg |
POP_JUMP_FORWARD_IF_TRUE | 115 | – | – | – | – | Pops the top; if true, jumps forward by arg |
POP_JUMP_IF_FALSE | – | 114 | 97 | 100 | 99 | Pops the top; if false, jumps forward by arg. Needs an exact bool from 3.13 |
POP_JUMP_IF_NONE | – | 129 | 98 | 101 | 100 | Pops the top; if None, jumps forward by arg |
POP_JUMP_IF_NOT_NONE | – | 128 | 99 | 102 | 101 | Pops the top; if not None, jumps forward by arg |
POP_JUMP_IF_TRUE | – | 115 | 100 | 103 | 102 | Pops the top; if true, jumps forward by arg. Needs an exact bool from 3.13 |
POP_TOP | 1 | 1 | 32 | 31 | 29 | Pops and discards the top |
PRECALL | 166 | – | – | – | – | Goes before CALL, to allow specialisation; arg is the argument count |
PREP_RERAISE_STAR | 88 | – | – | – | – | Pops two items, pushes the exception group to re-raise from try–except* |
PRINT_EXPR | 70 | – | – | – | – | Pops the top and prints it, in interactive mode |
PUSH_EXC_INFO | 35 | 35 | 33 | 32 | 30 | Pops a value, pushes the current exception, pushes the value back |
PUSH_NULL | 2 | 2 | 34 | 33 | 31 | Pushes NULL, for the calling sequence |
RAISE_VARARGS | 130 | 130 | 101 | 104 | 103 | Raises: arg 0 re-raises, 1 raises the top, 2 raises the item below the top with the top as its cause |
RERAISE | 119 | 119 | 102 | 105 | 104 | Re-raises the exception on top. If arg is nonzero, pops a value and restores f_lasti from it |
RESERVED | – | 17 | 17 | 17 | 17 | A reserved number. Executing it is an interpreter error |
RESUME | 151 | 151 | 149 | 128 | 128 | No visible effect; a point for tracing, debugging and optimisation checks. arg says where it is |
RETURN_CONST | – | 121 | 103 | – | – | Returns a constant. arg is a constant index |
RETURN_GENERATOR | 75 | 75 | 35 | 34 | 32 | Makes a generator, coroutine or async generator from the frame and returns it |
RETURN_VALUE | 83 | 83 | 36 | 35 | 33 | Returns the top of the stack |
SEND | 123 | 123 | 104 | 106 | 105 | Sends a value into a sub-generator, for yield from and await. When the sub-generator finishes, it jumps forward by arg |
SETUP_ANNOTATIONS | 85 | 85 | 37 | 36 | 34 | Makes __annotations__ an empty dictionary in the locals, if it is missing |
SET_ADD | 146 | 146 | 105 | 107 | 106 | Pops an item and adds it to the set arg places down |
SET_FUNCTION_ATTRIBUTE | – | – | 106 | 108 | 107 | Pops a function and a value, sets one attribute selected by arg, and pushes the function back |
SET_UPDATE | 163 | 163 | 107 | 109 | 108 | Pops an iterable and adds its items to the set arg places down |
STORE_ATTR | 95 | 95 | 108 | 110 | 109 | Pops an object and a value; sets the attribute. arg is a name index |
STORE_DEREF | 138 | 138 | 109 | 111 | 110 | Pops a value into the cell in slot arg |
STORE_FAST | 125 | 125 | 110 | 112 | 111 | Pops a value into the local in slot arg |
STORE_FAST_LOAD_FAST | – | – | 111 | 113 | 112 | Pops a value into slot arg >> 4, then pushes the local in slot arg & 15 |
STORE_FAST_STORE_FAST | – | – | 112 | 114 | 113 | Pops two values into slots arg >> 4 and arg & 15 |
STORE_GLOBAL | 97 | 97 | 113 | 115 | 114 | Pops a value into a global. arg is a name index |
STORE_NAME | 90 | 90 | 114 | 116 | 115 | Pops a value into a name. arg is a name index |
STORE_SLICE | – | 27 | 38 | 37 | 35 | Pops end, start, container and value; container[start:end] = value |
STORE_SUBSCR | 60 | 60 | 39 | 38 | 36 | Pops key, container and value; container[key] = value |
SWAP | 99 | 99 | 115 | 117 | 116 | Swaps the top with the item arg places down, counting the top as 1 |
TO_BOOL | – | – | 40 | 39 | 37 | Replaces the top with bool() of it |
TRACE_RECORD | – | – | – | – | 255 | Used by the interpreter when recording traces for the optimiser. Not expected in a file |
UNARY_INVERT | 15 | 15 | 41 | 40 | 38 | Replaces the top with ~ of it |
UNARY_NEGATIVE | 11 | 11 | 42 | 41 | 39 | Replaces the top with - of it |
UNARY_NOT | 12 | 12 | 43 | 42 | 40 | Replaces the top with not of it. Needs an exact bool from 3.13 |
UNARY_POSITIVE | 10 | – | – | – | – | Replaces the top with + of it. From 3.12 this is CALL_INTRINSIC_1 |
UNPACK_EX | 94 | 94 | 116 | 118 | 117 | Unpacks the top with a starred target. The low byte of arg is the count before the list, and the high byte the count after it |
UNPACK_SEQUENCE | 92 | 92 | 117 | 119 | 118 | Replaces the top with its arg items, pushed right to left |
WITH_EXCEPT_START | 49 | 49 | 44 | 43 | 41 | Calls the __exit__ function below the exception on top, for with |
YIELD_VALUE | 86 | 150 | 118 | 120 | 119 | Pops the top and yields it. In 3.12, arg is the exception block depth. From 3.13, arg is 1 inside yield from or await, otherwise 0 |
Comparison operators
COMPARE_OP’s argument holds an index into this list. Where the index is
kept depends on the release.
| Index | Operator |
|---|---|
| 0 | < |
| 1 | <= |
| 2 | == |
| 3 | != |
| 4 | > |
| 5 | >= |
| Release | Index | Other bits |
|---|---|---|
| 3.11 | arg | None |
| 3.12 | arg >> 4 | The low four bits are a mask used by the interpreter |
| 3.13 on | arg >> 5 | Bit 4 (arg & 16): convert the result to bool |
BINARY_OP operators
| arg | Operator | arg | Operator |
|---|---|---|---|
| 0 | + | 13 | += |
| 1 | & | 14 | &= |
| 2 | // | 15 | //= |
| 3 | << | 16 | <<= |
| 4 | @ | 17 | @= |
| 5 | * | 18 | *= |
| 6 | % | 19 | %= |
| 7 | | | 20 | |= |
| 8 | ** | 21 | **= |
| 9 | >> | 22 | >>= |
| 10 | - | 23 | -= |
| 11 | / | 24 | /= |
| 12 | ^ | 25 | ^= |
| 26 | [], subscript, from 3.14 |
Intrinsics
CALL_INTRINSIC_1 (from 3.12):
| arg | Name | Does |
|---|---|---|
| 0 | INTRINSIC_1_INVALID | Not valid |
| 1 | INTRINSIC_PRINT | Prints the argument to standard output, in the REPL |
| 2 | INTRINSIC_IMPORT_STAR | import * for the named module |
| 3 | INTRINSIC_STOPITERATION_ERROR | Extracts the return value from a StopIteration |
| 4 | INTRINSIC_ASYNC_GEN_WRAP | Wraps an async generator value |
| 5 | INTRINSIC_UNARY_POSITIVE | Unary + |
| 6 | INTRINSIC_LIST_TO_TUPLE | Converts a list to a tuple |
| 7 | INTRINSIC_TYPEVAR | Creates a TypeVar |
| 8 | INTRINSIC_PARAMSPEC | Creates a ParamSpec |
| 9 | INTRINSIC_TYPEVARTUPLE | Creates a TypeVarTuple |
| 10 | INTRINSIC_SUBSCRIPT_GENERIC | typing.Generic subscripted with the argument |
| 11 | INTRINSIC_TYPEALIAS | Creates a TypeAliasType, for the type statement |
CALL_INTRINSIC_2 (from 3.12):
| arg | Name | Does |
|---|---|---|
| 0 | INTRINSIC_2_INVALID | Not valid |
| 1 | INTRINSIC_PREP_RERAISE_STAR | Computes the exception group to raise from try–except* |
| 2 | INTRINSIC_TYPEVAR_WITH_BOUND | Creates a TypeVar with a bound |
| 3 | INTRINSIC_TYPEVAR_WITH_CONSTRAINTS | Creates a TypeVar with constraints |
| 4 | INTRINSIC_SET_FUNCTION_TYPE_PARAMS | Sets a function’s __type_params__ |
| 5 | INTRINSIC_SET_TYPEPARAM_DEFAULT | Sets a type parameter’s default (from 3.13) |
Function flags
The argument of MAKE_FUNCTION in 3.11 and 3.12, and of
SET_FUNCTION_ATTRIBUTE from 3.13, is one of these bits.
| Bit | Value |
|---|---|
| 0x01 | Tuple of defaults for positional parameters |
| 0x02 | Dictionary of keyword-only defaults |
| 0x04 | Tuple of strings holding parameter annotations |
| 0x08 | Tuple of cells for free variables, the closure |
| 0x10 | The annotate function (from 3.14) |
RESUME argument
| Releases | Bits | Meaning |
|---|---|---|
| 3.11, 3.12 | Whole argument | 0 start of a function; 1 after yield; 2 after yield from; 3 after await |
| 3.13, 3.14 | Bits 0–1 | The same four locations |
| 3.13, 3.14 | Bit 2 | Set when the RESUME is at except-depth 1 |
| 3.15 | Bits 0–2 | The same four locations, and 4 for the start of a generator expression |
| 3.15 | Bit 3 | Set when the RESUME is at except-depth 1 |
LOAD_COMMON_CONSTANT
| arg | Constant | Releases |
|---|---|---|
| 0 | AssertionError | 3.14 on |
| 1 | NotImplementedError | 3.14 on |
| 2 | tuple | 3.14 on |
| 3 | all | 3.14 on |
| 4 | any | 3.14 on |
| 5 | list | 3.15 |
| 6 | set | 3.15 |
| 7 | None | 3.15 |
| 8 | The empty string | 3.15 |
| 9 | True | 3.15 |
| 10 | False | 3.15 |
| 11 | −1 | 3.15 |
LOAD_SPECIAL
| arg | Method |
|---|---|
| 0 | __enter__ |
| 1 | __exit__ |
| 2 | __aenter__ |
| 3 | __aexit__ |