Guido van Rossum | b62b6d1 | 1997-11-18 15:10:53 +0000 | [diff] [blame] | 1 | \section{Standard module \sectcode{dis}} % If implemented in Python |
| 2 | \stmodindex{dis} |
| 3 | |
| 4 | \label{module-dis} |
| 5 | |
| 6 | The \code{dis} module supports the analysis of Python byte code by |
| 7 | disassembling it. Since there is no Python assembler, this module |
| 8 | defines the Python assembly language. The Python byte code which |
| 9 | this module takes as an input is defined in the file |
| 10 | \code{Include/opcode.h} and used by the compiler and the interpreter. |
| 11 | |
| 12 | Example: Given the function myfunc |
| 13 | |
| 14 | \bcode\begin{verbatim} |
| 15 | def myfunc(alist): |
| 16 | return len(alist) |
| 17 | \end{verbatim}\ecode |
| 18 | |
| 19 | the following command can be used to get the disassembly of myfunc: |
| 20 | |
| 21 | \begin{verbatim} |
| 22 | >>> dis.dis(myfunc) |
| 23 | 0 SET_LINENO 1 |
| 24 | |
| 25 | 3 SET_LINENO 2 |
| 26 | 6 LOAD_GLOBAL 0 (len) |
| 27 | 9 LOAD_FAST 0 (alist) |
| 28 | 12 CALL_FUNCTION 1 |
| 29 | 15 RETURN_VALUE |
| 30 | 16 LOAD_CONST 0 (None) |
| 31 | 19 RETURN_VALUE |
| 32 | \end{verbatim} |
| 33 | |
| 34 | The \code{dis} module defines the following functions: |
| 35 | |
| 36 | \renewcommand{\indexsubitem}{(in module dis)} |
| 37 | |
| 38 | % ---- 3.2. ---- |
| 39 | % For each function, use a ``funcdesc'' block. This has exactly two |
| 40 | % parameters (each parameters is contained in a set of curly braces): |
| 41 | % the first parameter is the function name (this automatically |
| 42 | % generates an index entry); the second parameter is the function's |
| 43 | % argument list. If there are no arguments, use an empty pair of |
| 44 | % curly braces. If there is more than one argument, separate the |
| 45 | % arguments with backslash-comma. Optional parts of the parameter |
| 46 | % list are contained in \optional{...} (this generates a set of square |
| 47 | % brackets around its parameter). Arguments are automatically set in |
| 48 | % italics in the parameter list. Each argument should be mentioned at |
| 49 | % least once in the description; each usage (even inside \code{...}) |
| 50 | % should be enclosed in \var{...}. |
| 51 | |
| 52 | \begin{funcdesc}{dis}{\optional{bytesource}} |
| 53 | Disassemble the \var{bytesource} object. \var{bytesource} can denote |
| 54 | either a class, a method, a function, or a code object. For a class, |
| 55 | it disassembles all methods. For a single code sequence, it prints |
| 56 | one line per byte code instruction. If no object is provided, it |
| 57 | disassembles the last traceback. |
| 58 | \end{funcdesc} |
| 59 | |
| 60 | \begin{funcdesc}{distb}{\optional{tb}} |
| 61 | Disassembles the top-of-stack function of a traceback, using the last |
| 62 | traceback if none was passed. The instruction causing the exception |
| 63 | is indicated. |
| 64 | \end{funcdesc} |
| 65 | |
| 66 | \begin{funcdesc}{disassemble}{code\optional{\, lasti}} |
| 67 | Disassembles a code object, indicating the last instruction if \var{lasti} |
| 68 | was provided. The output is divided in the following columns: |
| 69 | \begin{itemize} |
| 70 | \item the current instruction, indicated as \code{-->}, |
| 71 | \item a labelled instruction, indicated with \code{>>}, |
| 72 | \item the address of the instruction, |
| 73 | \item the operation code name, |
| 74 | \item operation parameters, and |
| 75 | \item interpretation of the parameters in parentheses. |
| 76 | \end{itemize} |
| 77 | The parameter interpretation recognizes local and global |
| 78 | variable names, constant values, branch targets, and compare |
| 79 | operators. |
| 80 | \end{funcdesc} |
| 81 | |
| 82 | \begin{funcdesc}{disco}{code\optional{\, lasti}} |
| 83 | A synonym for disassemble. It is more convenient to type, and kept |
| 84 | for compatibility with earlier Python releases. |
| 85 | \end{funcdesc} |
| 86 | |
| 87 | \begin{datadesc}{opname} |
| 88 | Sequence of a operation names, indexable using the byte code. |
| 89 | \end{datadesc} |
| 90 | |
| 91 | \begin{datadesc}{cmp_op} |
| 92 | Sequence of all compare operation names. |
| 93 | \end{datadesc} |
| 94 | |
| 95 | \begin{datadesc}{hasconst} |
| 96 | Sequence of byte codes that have a constant parameter. |
| 97 | \end{datadesc} |
| 98 | |
| 99 | \begin{datadesc}{hasname} |
| 100 | Sequence of byte codes that access a attribute by name. |
| 101 | \end{datadesc} |
| 102 | |
| 103 | \begin{datadesc}{hasjrel} |
| 104 | Sequence of byte codes that have a relative jump target. |
| 105 | \end{datadesc} |
| 106 | |
| 107 | \begin{datadesc}{hasjabs} |
| 108 | Sequence of byte codes that have an absolute jump target. |
| 109 | \end{datadesc} |
| 110 | |
| 111 | \begin{datadesc}{haslocal} |
| 112 | Sequence of byte codes that access a a local variable. |
| 113 | \end{datadesc} |
| 114 | |
| 115 | \begin{datadesc}{hascompare} |
| 116 | Sequence of byte codes of boolean operations. |
| 117 | \end{datadesc} |
| 118 | |
| 119 | \subsection{Python Byte Code Instructions} |
| 120 | |
| 121 | The Python compiler currently generates the following byte code |
| 122 | instructions. |
| 123 | |
| 124 | \renewcommand{\indexsubitem}{(byte code insns)} |
| 125 | |
| 126 | \begin{funcdesc}{STOP_CODE}{} |
| 127 | Indicates end-of-code to the compiler, not used by the interpreter. |
| 128 | \end{funcdesc} |
| 129 | |
| 130 | \begin{funcdesc}{POP_TOP}{} |
| 131 | Removes the top-of-stack (TOS) item. |
| 132 | \end{funcdesc} |
| 133 | |
| 134 | \begin{funcdesc}{ROT_TWO}{} |
| 135 | Swaps the two top-most stack items. |
| 136 | \end{funcdesc} |
| 137 | |
| 138 | \begin{funcdesc}{ROT_THREE}{} |
| 139 | Lifts second and third stack item on position up, moves top down |
| 140 | to position three. |
| 141 | \end{funcdesc} |
| 142 | |
| 143 | \begin{funcdesc}{DUP_TOP}{} |
| 144 | Duplicates the reference on top of the stack. |
| 145 | \end{funcdesc} |
| 146 | |
| 147 | Unary Operations take the top of the stack, apply the operation, and |
| 148 | push the result back on the stack. |
| 149 | |
| 150 | \begin{funcdesc}{UNARY_POSITIVE}{} |
| 151 | Implements \code{TOS = +TOS}. |
| 152 | \end{funcdesc} |
| 153 | |
| 154 | \begin{funcdesc}{UNARY_NEG}{} |
| 155 | Implements \code{TOS = -TOS}. |
| 156 | \end{funcdesc} |
| 157 | |
| 158 | \begin{funcdesc}{UNARY_NOT}{} |
| 159 | Implements \code{TOS = not TOS}. |
| 160 | \end{funcdesc} |
| 161 | |
| 162 | \begin{funcdesc}{UNARY_CONVERT}{} |
| 163 | Implements \code{TOS = `TOS`}. |
| 164 | \end{funcdesc} |
| 165 | |
| 166 | \begin{funcdesc}{UNARY_INVERT}{} |
| 167 | Implements \code{TOS = ~TOS}. |
| 168 | \end{funcdesc} |
| 169 | |
| 170 | Binary operations remove the top of the stack (TOS) and the second top-most |
| 171 | stack item (TOS1) from the stack. They perform the operation, and put the |
| 172 | result back on the stack. |
| 173 | |
| 174 | \begin{funcdesc}{BINARY_POWER}{} |
| 175 | Implements \code{TOS = TOS1 ** TOS}. |
| 176 | \end{funcdesc} |
| 177 | |
| 178 | \begin{funcdesc}{BINARY_MULTIPLY}{} |
| 179 | Implements \code{TOS = TOS1 * TOS}. |
| 180 | \end{funcdesc} |
| 181 | |
| 182 | \begin{funcdesc}{BINARY_DIVIDE}{} |
| 183 | Implements \code{TOS = TOS1 / TOS}. |
| 184 | \end{funcdesc} |
| 185 | |
| 186 | \begin{funcdesc}{BINARY_MODULO}{} |
| 187 | Implements \code{TOS = TOS1 \% TOS}. |
| 188 | \end{funcdesc} |
| 189 | |
| 190 | \begin{funcdesc}{BINARY_ADD}{} |
| 191 | Implements \code{TOS = TOS1 + TOS}. |
| 192 | \end{funcdesc} |
| 193 | |
| 194 | \begin{funcdesc}{BINARY_SUBTRACT}{} |
| 195 | Implements \code{TOS = TOS1 - TOS}. |
| 196 | \end{funcdesc} |
| 197 | |
| 198 | \begin{funcdesc}{BINARY_SUBSCR}{} |
| 199 | Implements \code{TOS = TOS1[TOS] }. |
| 200 | \end{funcdesc} |
| 201 | |
| 202 | \begin{funcdesc}{BINARY_LSHIFT}{} |
| 203 | Implements \code{TOS = TOS1 << TOS }. |
| 204 | \end{funcdesc} |
| 205 | |
| 206 | \begin{funcdesc}{BINARY_RSHIFT}{} |
| 207 | Implements \code{TOS = TOS1 << TOS }. |
| 208 | \end{funcdesc} |
| 209 | |
| 210 | \begin{funcdesc}{BINARY_AND}{} |
| 211 | Implements \code{TOS = TOS1 and TOS }. |
| 212 | \end{funcdesc} |
| 213 | |
| 214 | \begin{funcdesc}{BINARY_XOR}{} |
| 215 | Implements \code{TOS = TOS1 \^{ }TOS }. |
| 216 | \end{funcdesc} |
| 217 | |
| 218 | \begin{funcdesc}{BINARY_OR}{} |
| 219 | Implements \code{TOS = TOS1 or TOS }. |
| 220 | \end{funcdesc} |
| 221 | |
| 222 | The slice opcodes take up to three parameters. |
| 223 | |
| 224 | \begin{funcdesc}{SLICE+0}{} |
| 225 | Implements \code{TOS = TOS[:]}. |
| 226 | \end{funcdesc} |
| 227 | |
| 228 | \begin{funcdesc}{SLICE+1}{} |
| 229 | Implements \code{TOS = TOS1[TOS:]}. |
| 230 | \end{funcdesc} |
| 231 | |
| 232 | \begin{funcdesc}{SLICE+2}{} |
| 233 | Implements \code{TOS = TOS1[:TOS1]}. |
| 234 | \end{funcdesc} |
| 235 | |
| 236 | \begin{funcdesc}{SLICE+3}{} |
| 237 | Implements \code{TOS = TOS2[TOS1:TOS]}. |
| 238 | \end{funcdesc} |
| 239 | |
| 240 | Slice assignment needs even an additional parameter. As any statement, |
| 241 | they put nothing on the stack. |
| 242 | |
| 243 | \begin{funcdesc}{STORE_SLICE+0}{} |
| 244 | Implements \code{TOS[:]=TOS1}. |
| 245 | \end{funcdesc} |
| 246 | |
| 247 | \begin{funcdesc}{STORE_SLICE+1}{} |
| 248 | Implements \code{TOS1[TOS:]=TOS2}. |
| 249 | \end{funcdesc} |
| 250 | |
| 251 | \begin{funcdesc}{STORE_SLICE+2}{} |
| 252 | Implements \code{TOS1[:TOS]=TOS2}. |
| 253 | \end{funcdesc} |
| 254 | |
| 255 | \begin{funcdesc}{STORE_SLICE+3}{} |
| 256 | Implements \code{TOS2[TOS1:TOS]=TOS3}. |
| 257 | \end{funcdesc} |
| 258 | |
| 259 | \begin{funcdesc}{DELETE_SLICE+0}{} |
| 260 | Implements \code{del TOS[:]}. |
| 261 | \end{funcdesc} |
| 262 | |
| 263 | \begin{funcdesc}{DELETE_SLICE+1}{} |
| 264 | Implements \code{del TOS1[TOS:]}. |
| 265 | \end{funcdesc} |
| 266 | |
| 267 | \begin{funcdesc}{DELETE_SLICE+2}{} |
| 268 | Implements \code{del TOS1[:TOS]}. |
| 269 | \end{funcdesc} |
| 270 | |
| 271 | \begin{funcdesc}{DELETE_SLICE+3}{} |
| 272 | Implements \code{del TOS2[TOS1:TOS]}. |
| 273 | \end{funcdesc} |
| 274 | |
| 275 | \begin{funcdesc}{STORE_SUBSCR}{} |
| 276 | Implements \code{TOS1[TOS]=TOS2}. |
| 277 | \end{funcdesc} |
| 278 | |
| 279 | \begin{funcdesc}{DELETE_SUBSCR}{} |
| 280 | Implements \code{del TOS1[TOS]}. |
| 281 | \end{funcdesc} |
| 282 | |
| 283 | \begin{funcdesc}{PRINT_EXPR}{} |
| 284 | Implements the expression statement for the interactive mode. TOS is |
| 285 | removed from the stack and printed. In non-interactive mode, an |
| 286 | expression statement is terminated with POP_STACK. |
| 287 | \end{funcdesc} |
| 288 | |
| 289 | \begin{funcdesc}{PRINT_ITEM}{} |
| 290 | Prints TOS. There is one such instruction for |
| 291 | each item in the print statement. |
| 292 | \end{funcdesc} |
| 293 | |
| 294 | \begin{funcdesc}{PRINT_NEWLINE}{} |
| 295 | Prints a new line on \code{sys.stdout}. This is generated as the |
| 296 | last operation of a print statement, unless the statement ends |
| 297 | with a comma. |
| 298 | \end{funcdesc} |
| 299 | |
| 300 | \begin{funcdesc}{BREAK_LOOP}{} |
| 301 | Terminates a loop due to a break statement. |
| 302 | \end{funcdesc} |
| 303 | |
| 304 | \begin{funcdesc}{LOAD_LOCALS}{} |
| 305 | Pushes a reference to the locals of the current scope on the stack. |
| 306 | This is used in the code for a class definition: After the class body |
| 307 | is evaluated, the locals are passed to the class definition. |
| 308 | \end{funcdesc} |
| 309 | |
| 310 | \begin{funcdesc}{RETURN_VALUE}{} |
| 311 | Returns with TOS to the caller of the function. |
| 312 | \end{funcdesc} |
| 313 | |
| 314 | \begin{funcdesc}{EXEC_STMT}{} |
| 315 | Implements \code{exec TOS2,TOS1,TOS}. The compiler fills |
| 316 | missing optional parameters with None. |
| 317 | \end{funcdesc} |
| 318 | |
| 319 | \begin{funcdesc}{POP_BLOCK}{} |
| 320 | Removes one block from the block stack. Per frame, there is a |
| 321 | stack of blocks, denoting nested loops, try statements, and such. |
| 322 | \end{funcdesc} |
| 323 | |
| 324 | \begin{funcdesc}{END_FINALLY}{} |
| 325 | Terminates a finally-block. The interpreter recalls whether the |
| 326 | exception has to be re-raised, or whether the function returns, |
| 327 | and continues with the outer-next block. |
| 328 | \end{funcdesc} |
| 329 | |
| 330 | \begin{funcdesc}{BUILD_CLASS}{} |
| 331 | Creates a new class object. TOS is the methods dictionary, TOS1 |
| 332 | the tuple of the names of the base classes, and TOS2 the class name. |
| 333 | \end{funcdesc} |
| 334 | |
| 335 | All of the following opcodes expect arguments. An argument is two |
| 336 | bytes, with the more significant byte last. |
| 337 | |
| 338 | \begin{funcdesc}{STORE_NAME}{namei} |
| 339 | Implements \code{name = TOS}. \var{namei} is the index of \var{name} |
| 340 | in the attribute \code{co_names} of the code object. |
| 341 | The compiler tries to use STORE_LOCAL or STORE_GLOBAL if possible. |
| 342 | \end{funcdesc} |
| 343 | |
| 344 | \begin{funcdesc}{DELETE_NAME}{namei} |
| 345 | Implements \code{del name}, where \var{namei} is the index into |
| 346 | \code{co_names} attribute of the code object. |
| 347 | \end{funcdesc} |
| 348 | |
| 349 | \begin{funcdesc}{UNPACK_TUPLE}{count} |
| 350 | Unpacks TOS into \var{count} individual values, which are put onto |
| 351 | the stack right-to-left. |
| 352 | \end{funcdesc} |
| 353 | |
| 354 | \begin{funcdesc}{UNPACK_LIST}{count} |
| 355 | Unpacks TOS into \var{count} individual values. |
| 356 | \end{funcdesc} |
| 357 | |
| 358 | %\begin{funcdesc}{UNPACK_ARG}{count} |
| 359 | %This opcode is obsolete. |
| 360 | %\end{funcdesc} |
| 361 | |
| 362 | \begin{funcdesc}{STORE_ATTR}{namei} |
| 363 | Implements \code{TOS.name = TOS1}, where \var{namei} is the index |
| 364 | of name in \code{co_names}. |
| 365 | \end{funcdesc} |
| 366 | |
| 367 | \begin{funcdesc}{DELETE_ATTR}{namei} |
| 368 | Implements \code{del TOS.name}, using \var{namei} as index into |
| 369 | \code{co_names}. |
| 370 | \end{funcdesc} |
| 371 | |
| 372 | \begin{funcdesc}{STORE_GLOBAL}{namei} |
| 373 | Works as STORE_NAME, but stores the name as a global. |
| 374 | \end{funcdesc} |
| 375 | |
| 376 | \begin{funcdesc}{DELETE_GLOBAL}{namei} |
| 377 | Works as DELETE_NAME, but deletes a global name. |
| 378 | \end{funcdesc} |
| 379 | |
| 380 | %\begin{funcdesc}{UNPACK_VARARG}{argc} |
| 381 | %This opcode is obsolete. |
| 382 | %\end{funcdesc} |
| 383 | |
| 384 | \begin{funcdesc}{LOAD_CONST}{consti} |
| 385 | Pushes \code{co_consts[consti]} onto the stack. |
| 386 | \end{funcdesc} |
| 387 | |
| 388 | \begin{funcdesc}{LOAD_NAME}{namei} |
| 389 | Pushes the value associated with \code{co_names[namei]} onto the stack. |
| 390 | \end{funcdesc} |
| 391 | |
| 392 | \begin{funcdesc}{BUILD_TUPLE}{count} |
| 393 | Creates a tuple consuming \var{count} items from the stack, and pushes |
| 394 | the resulting tuple onto the stack. |
| 395 | \end{funcdesc} |
| 396 | |
| 397 | \begin{funcdesc}{BUILD_LIST}{count} |
| 398 | Works as \code{BUILD_TUPLE}, but creates a list. |
| 399 | \end{funcdesc} |
| 400 | |
| 401 | \begin{funcdesc}{BUILD_MAP}{zero} |
| 402 | Pushes an empty dictionary object onto the stack. The argument is ignored |
| 403 | and set to zero by the compiler. |
| 404 | \end{funcdesc} |
| 405 | |
| 406 | \begin{funcdesc}{LOAD_ATTR}{namei} |
| 407 | Replaces TOS with \code{getattr(TOS,co_names[namei]}. |
| 408 | \end{funcdesc} |
| 409 | |
| 410 | \begin{funcdesc}{COMPARE_OP}{opname} |
| 411 | Performs a boolean operation. The operation name can be found |
| 412 | in \code{cmp_op[opname]}. |
| 413 | \end{funcdesc} |
| 414 | |
| 415 | \begin{funcdesc}{IMPORT_NAME}{namei} |
| 416 | Imports the module \code{co_names[namei]}. The module object is |
| 417 | pushed onto the stack. The current name space is not affect: for a |
| 418 | proper import statement, a subsequent \code{STORE_FAST} instruction |
| 419 | modifies the name space. |
| 420 | \end{funcdesc} |
| 421 | |
| 422 | \begin{funcdesc}{IMPORT_FROM}{namei} |
| 423 | Imports the attribute \code{co_names[namei]}. The module to import |
| 424 | from is found in TOS and left there. |
| 425 | \end{funcdesc} |
| 426 | |
| 427 | \begin{funcdesc}{JUMP_FORWARD}{delta} |
| 428 | Increments byte code counter by \var{delta}. |
| 429 | \end{funcdesc} |
| 430 | |
| 431 | \begin{funcdesc}{JUMP_IF_TRUE}{delta} |
| 432 | If TOS is true, increment the byte code counter by \var{delta}. TOS is |
| 433 | left on the stack. |
| 434 | \end{funcdesc} |
| 435 | |
| 436 | \begin{funcdesc}{JUMP_IF_FALSE}{delta} |
| 437 | If TOS is false, increment the byte code counter by \var{delta}. TOS |
| 438 | is not changed. |
| 439 | \end{funcdesc} |
| 440 | |
| 441 | \begin{funcdesc}{JUMP_ABSOLUTE}{target} |
| 442 | Set byte code counter to \var{target}. |
| 443 | \end{funcdesc} |
| 444 | |
| 445 | \begin{funcdesc}{FOR_LOOP}{delta} |
| 446 | Iterate over a sequence. TOS is the current index, TOS1 the sequence. |
| 447 | First, the next element is computed. If the sequence is exhausted, |
| 448 | increment byte code counter by \var{delta}. Otherwise, push the |
| 449 | sequence, the incremented counter, and the current item onto the stack. |
| 450 | \end{funcdesc} |
| 451 | |
| 452 | %\begin{funcdesc}{LOAD_LOCAL}{namei} |
| 453 | %This opcode is obsolete. |
| 454 | %\end{funcdesc} |
| 455 | |
| 456 | \begin{funcdesc}{LOAD_GLOBAL}{namei} |
| 457 | Loads the global named \code{co_names[namei]} onto the stack. |
| 458 | \end{funcdesc} |
| 459 | |
| 460 | %\begin{funcdesc}{SET_FUNC_ARGS}{argc} |
| 461 | %This opcode is obsolete. |
| 462 | %\end{funcdesc} |
| 463 | |
| 464 | \begin{funcdesc}{SETUP_LOOP}{delta} |
| 465 | Pushes a block for a loop onto the block stack. The block spans |
| 466 | from the current instruction with a size of \var{delta} bytes. |
| 467 | \end{funcdesc} |
| 468 | |
| 469 | \begin{funcdesc}{SETUP_EXCEPT}{delta} |
| 470 | Pushes a try block from a try-except clause onto the block stack. |
| 471 | \var{delta} points to the first except block. |
| 472 | \end{funcdesc} |
| 473 | |
| 474 | \begin{funcdesc}{SETUP_FINALLY}{delta} |
| 475 | Pushes a try block from a try-except clause onto the block stack. |
| 476 | \var{delta} points to the finally block. |
| 477 | \end{funcdesc} |
| 478 | |
| 479 | \begin{funcdesc}{LOAD_FAST}{var_num} |
| 480 | Pushes a reference to the local \code{co_varnames[var_num]} onto |
| 481 | the stack. |
| 482 | \end{funcdesc} |
| 483 | |
| 484 | \begin{funcdesc}{STORE_FAST}{var_num} |
| 485 | Stores TOS into the local \code{co_varnames[var_num]}. |
| 486 | \end{funcdesc} |
| 487 | |
| 488 | \begin{funcdesc}{DELETE_FAST}{var_num} |
| 489 | Deletes local \code{co_varnames[var_num]}. |
| 490 | \end{funcdesc} |
| 491 | |
| 492 | \begin{funcdesc}{SET_LINE_NO}{lineno} |
| 493 | Sets the current line number to \var{lineno}. |
| 494 | \end{funcdesc} |
| 495 | |
| 496 | \begin{funcdesc}{RAISE_VARARGS}{argc} |
| 497 | Raises an exception. \var{argc} indicates the number of parameters |
| 498 | to the raise statement, ranging from 1 to 3. The handler will find |
| 499 | the traceback as TOS2, the parameter as TOS1, and the exception |
| 500 | as TOS. |
| 501 | \end{funcdesc} |
| 502 | |
| 503 | \begin{funcdesc}{CALL_FUNCTION}{argc} |
| 504 | Calls a function. The low byte of \var{argc} indicates the number of |
| 505 | positional parameters, the high byte the number of keyword parameters. |
| 506 | On the stack, the opcode finds the keyword parameters first. For each |
| 507 | keyword argument, the value is on top of the key. Below the keyword |
| 508 | parameters, the positional parameters are on the stack, with the |
| 509 | right-most parameter on top. Below the parameters, the function object |
| 510 | to call is on the stack. |
| 511 | \end{funcdesc} |
| 512 | |
| 513 | \begin{funcdesc}{MAKE_FUNCTION}{argc} |
| 514 | Pushes a new function object on the stack. TOS is the code associated |
| 515 | with the function. The function object is defined to have \var{argc} |
| 516 | default parameters, which are found below TOS. |
| 517 | \end{funcdesc} |
| 518 | |
| 519 | \begin{funcdesc}{BUILD_SLICE}{argc} |
| 520 | Pushes a slice object on the stack. If \var{argc} is three, creates |
| 521 | \code{TOS3[TOS2:TOS1:TOS]}. Otherwise, expects three arguments. |
| 522 | \end{funcdesc} |
| 523 | |
| 524 | |