| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0a222db commit 59585d6
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,11 +36,12 @@ the following command can be used to display the disassembly of | |||
| 36 | 36 | >>> dis.dis(myfunc) | |
| 37 | 37 | 1 0 RESUME 0 | |
| 38 | 38 | ||
| 39 | - 2 2 LOAD_GLOBAL 0 (len) | ||
| 40 | - 4 LOAD_FAST 0 (alist) | ||
| 41 | - 6 PRECALL_FUNCTION 1 | ||
| 42 | - 8 CALL 0 | ||
| 43 | - 10 RETURN_VALUE | ||
| 39 | + 2 2 PUSH_NULL | ||
| 40 | + 4 LOAD_GLOBAL 0 (len) | ||
| 41 | + 6 LOAD_FAST 0 (alist) | ||
| 42 | + 8 PRECALL 1 | ||
| 43 | + 10 CALL 1 | ||
| 44 | + 12 RETURN_VALUE | ||
| 44 | 45 | ||
| 45 | 46 | (The "2" is a line number). | |
| 46 | 47 | ||
@@ -106,9 +107,10 @@ Example:: | |||
| 106 | 107 | ... print(instr.opname) | |
| 107 | 108 | ... | |
| 108 | 109 | RESUME | |
| 110 | + PUSH_NULL | ||
| 109 | 111 | LOAD_GLOBAL | |
| 110 | 112 | LOAD_FAST | |
| 111 | - PRECALL_FUNCTION | ||
| 113 | + PRECALL | ||
| 112 | 114 | CALL | |
| 113 | 115 | RETURN_VALUE | |
| 114 | 116 | ||
@@ -1063,18 +1065,28 @@ iterations of the loop. | |||
| 1063 | 1065 | with ``__cause__`` set to ``TOS``) | |
| 1064 | 1066 | ||
| 1065 | 1067 | ||
| 1066 | - .. opcode:: CALL (named) | ||
| 1068 | + .. opcode:: CALL (argc) | ||
| 1067 | 1069 | ||
| 1068 | - Calls a callable object with the number of positional arguments specified by | ||
| 1069 | - the preceding :opcode:`PRECALL_FUNCTION` or :opcode:`PRECALL_METHOD` and | ||
| 1070 | - the named arguments specified by the preceding :opcode:`KW_NAMES`, if any. | ||
| 1071 | - *named* indicates the number of named arguments. | ||
| 1072 | - On the stack are (in ascending order): | ||
| 1070 | + Calls a callable object with the number of arguments specified by ``argc``, | ||
| 1071 | + including the named arguments specified by the preceding | ||
| 1072 | + :opcode:`KW_NAMES`, if any. | ||
| 1073 | + On the stack are (in ascending order), either: | ||
| 1073 | 1074 | ||
| 1075 | + * NULL | ||
| 1074 | 1076 | * The callable | |
| 1075 | 1077 | * The positional arguments | |
| 1076 | 1078 | * The named arguments | |
| 1077 | 1079 | ||
| 1080 | + or: | ||
| 1081 | + | ||
| 1082 | + * The callable | ||
| 1083 | + * ``self`` | ||
| 1084 | + * The remaining positional arguments | ||
| 1085 | + * The named arguments | ||
| 1086 | + | ||
| 1087 | + ``argc`` is the total of the positional and named arguments, excluding | ||
| 1088 | + ``self`` when a ``NULL`` is not present. | ||
| 1089 | + | ||
| 1078 | 1090 | ``CALL`` pops all arguments and the callable object off the stack, | |
| 1079 | 1091 | calls the callable object with those arguments, and pushes the return value | |
| 1080 | 1092 | returned by the callable object. | |
@@ -1102,33 +1114,34 @@ iterations of the loop. | |||
| 1102 | 1114 | Loads a method named ``co_names[namei]`` from the TOS object. TOS is popped. | |
| 1103 | 1115 | This bytecode distinguishes two cases: if TOS has a method with the correct | |
| 1104 | 1116 | name, the bytecode pushes the unbound method and TOS. TOS will be used as | |
| 1105 | - the first argument (``self``) by :opcode:`PRECALL_METHOD` when calling the | ||
| 1117 | + the first argument (``self``) by :opcode:`CALL` when calling the | ||
| 1106 | 1118 | unbound method. Otherwise, ``NULL`` and the object return by the attribute | |
| 1107 | 1119 | lookup are pushed. | |
| 1108 | 1120 | ||
| 1109 | 1121 | .. versionadded:: 3.7 | |
| 1110 | 1122 | ||
| 1111 | 1123 | ||
| 1112 | - .. opcode:: PRECALL_METHOD (argc) | ||
| 1124 | + .. opcode:: PRECALL (argc) | ||
| 1113 | 1125 | ||
| 1114 | - Prefixes :opcode:`CALL` (possibly with an intervening ``KW_NAMES``). | ||
| 1115 | - This opcode is designed to be used with :opcode:`LOAD_METHOD`. | ||
| 1116 | - Sets internal variables, so that :opcode:`CALL` | ||
| 1117 | - clean up after :opcode:`LOAD_METHOD` correctly. | ||
| 1126 | + Prefixes :opcode:`CALL`. Logically this is a no op. | ||
| 1127 | + It exists to enable effective specialization of calls. | ||
| 1128 | + ``argc`` is the number of arguments as described in :opcode:`CALL`. | ||
| 1118 | 1129 | ||
| 1119 | 1130 | .. versionadded:: 3.11 | |
| 1120 | 1131 | ||
| 1121 | 1132 | ||
| 1122 | - .. opcode:: PRECALL_FUNCTION (args) | ||
| 1133 | + .. opcode:: PUSH_NULL | ||
| 1123 | 1134 | ||
| 1124 | - Prefixes :opcode:`CALL` (possibly with an intervening ``KW_NAMES``). | ||
| 1125 | - Sets internal variables, so that :opcode:`CALL` can execute correctly. | ||
| 1135 | + Pushes a ``NULL`` to the stack. | ||
| 1136 | + Used in the call sequence to match the ``NULL`` pushed by | ||
| 1137 | + :opcode:`LOAD_METHOD` for non-method calls. | ||
| 1126 | 1138 | ||
| 1127 | 1139 | .. versionadded:: 3.11 | |
| 1128 | 1140 | ||
| 1129 | 1141 | ||
| 1130 | 1142 | .. opcode:: KW_NAMES (i) | |
| 1131 | 1143 | ||
| 1144 | + Prefixes :opcode:`PRECALL`. | ||
| 1132 | 1145 | Stores a reference to ``co_consts[consti]`` into an internal variable | |
| 1133 | 1146 | for use by :opcode:`CALL`. ``co_consts[consti]`` must be a tuple of strings. | |
| 1134 | 1147 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -386,6 +386,7 @@ def _write_atomic(path, data, mode=0o666): | |||
| 386 | 386 | # ROT_TWO/ROT_THREE/ROT_FOUR/ROT_N with SWAP) | |
| 387 | 387 | # Python 3.11a5 3478 (New CALL opcodes) | |
| 388 | 388 | # Python 3.11a5 3479 (Add PUSH_NULL opcode) | |
| 389 | + # Python 3.11a5 3480 (New CALL opcodes, second iteration) | ||
| 389 | 390 | ||
| 390 | 391 | # Python 3.12 will start with magic number 3500 | |
| 391 | 392 | ||
@@ -403,7 +404,7 @@ def _write_atomic(path, data, mode=0o666): | |||
| 403 | 404 | # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array | |
| 404 | 405 | # in PC/launcher.c must also be updated. | |
| 405 | 406 | ||
| 406 | - MAGIC_NUMBER = (3479).to_bytes(2, 'little') + b'\r\n' | ||
| 407 | + MAGIC_NUMBER = (3480).to_bytes(2, 'little') + b'\r\n' | ||
| 407 | 408 | _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c | |
| 408 | 409 | ||
| 409 | 410 | _PYCACHE = '__pycache__' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments