Move setting of ioready 'wait' earlier in call chain, to
[python/dscho.git] / Doc / lib / libdis.tex
blob7bdd239aeb07a25e2d13281d84825773103fc74d
1 \section{\module{dis} ---
2 Disassembler for Python byte code}
4 \declaremodule{standard}{dis}
5 \modulesynopsis{Disassembler for Python byte code.}
8 The \module{dis} module supports the analysis of Python byte code by
9 disassembling it. Since there is no Python assembler, this module
10 defines the Python assembly language. The Python byte code which
11 this module takes as an input is defined in the file
12 \file{Include/opcode.h} and used by the compiler and the interpreter.
14 Example: Given the function \function{myfunc}:
16 \begin{verbatim}
17 def myfunc(alist):
18 return len(alist)
19 \end{verbatim}
21 the following command can be used to get the disassembly of
22 \function{myfunc()}:
24 \begin{verbatim}
25 >>> dis.dis(myfunc)
26 2 0 LOAD_GLOBAL 0 (len)
27 3 LOAD_FAST 0 (alist)
28 6 CALL_FUNCTION 1
29 9 RETURN_VALUE
30 10 LOAD_CONST 0 (None)
31 13 RETURN_VALUE
32 \end{verbatim}
34 (The ``2'' is a line number).
36 The \module{dis} module defines the following functions and constants:
38 \begin{funcdesc}{dis}{\optional{bytesource}}
39 Disassemble the \var{bytesource} object. \var{bytesource} can denote
40 either a module, a class, a method, a function, or a code object.
41 For a module, it disassembles all functions. For a class,
42 it disassembles all methods. For a single code sequence, it prints
43 one line per byte code instruction. If no object is provided, it
44 disassembles the last traceback.
45 \end{funcdesc}
47 \begin{funcdesc}{distb}{\optional{tb}}
48 Disassembles the top-of-stack function of a traceback, using the last
49 traceback if none was passed. The instruction causing the exception
50 is indicated.
51 \end{funcdesc}
53 \begin{funcdesc}{disassemble}{code\optional{, lasti}}
54 Disassembles a code object, indicating the last instruction if \var{lasti}
55 was provided. The output is divided in the following columns:
57 \begin{enumerate}
58 \item the line number, for the first instruction of each line
59 \item the current instruction, indicated as \samp{-->},
60 \item a labelled instruction, indicated with \samp{>\code{>}},
61 \item the address of the instruction,
62 \item the operation code name,
63 \item operation parameters, and
64 \item interpretation of the parameters in parentheses.
65 \end{enumerate}
67 The parameter interpretation recognizes local and global
68 variable names, constant values, branch targets, and compare
69 operators.
70 \end{funcdesc}
72 \begin{funcdesc}{disco}{code\optional{, lasti}}
73 A synonym for disassemble. It is more convenient to type, and kept
74 for compatibility with earlier Python releases.
75 \end{funcdesc}
77 \begin{datadesc}{opname}
78 Sequence of operation names, indexable using the byte code.
79 \end{datadesc}
81 \begin{datadesc}{cmp_op}
82 Sequence of all compare operation names.
83 \end{datadesc}
85 \begin{datadesc}{hasconst}
86 Sequence of byte codes that have a constant parameter.
87 \end{datadesc}
89 \begin{datadesc}{hasfree}
90 Sequence of byte codes that access a free variable.
91 \end{datadesc}
93 \begin{datadesc}{hasname}
94 Sequence of byte codes that access an attribute by name.
95 \end{datadesc}
97 \begin{datadesc}{hasjrel}
98 Sequence of byte codes that have a relative jump target.
99 \end{datadesc}
101 \begin{datadesc}{hasjabs}
102 Sequence of byte codes that have an absolute jump target.
103 \end{datadesc}
105 \begin{datadesc}{haslocal}
106 Sequence of byte codes that access a local variable.
107 \end{datadesc}
109 \begin{datadesc}{hascompare}
110 Sequence of byte codes of Boolean operations.
111 \end{datadesc}
113 \subsection{Python Byte Code Instructions}
114 \label{bytecodes}
116 The Python compiler currently generates the following byte code
117 instructions.
119 \setindexsubitem{(byte code insns)}
121 \begin{opcodedesc}{STOP_CODE}{}
122 Indicates end-of-code to the compiler, not used by the interpreter.
123 \end{opcodedesc}
125 \begin{opcodedesc}{POP_TOP}{}
126 Removes the top-of-stack (TOS) item.
127 \end{opcodedesc}
129 \begin{opcodedesc}{ROT_TWO}{}
130 Swaps the two top-most stack items.
131 \end{opcodedesc}
133 \begin{opcodedesc}{ROT_THREE}{}
134 Lifts second and third stack item one position up, moves top down
135 to position three.
136 \end{opcodedesc}
138 \begin{opcodedesc}{ROT_FOUR}{}
139 Lifts second, third and forth stack item one position up, moves top down to
140 position four.
141 \end{opcodedesc}
143 \begin{opcodedesc}{DUP_TOP}{}
144 Duplicates the reference on top of the stack.
145 \end{opcodedesc}
147 Unary Operations take the top of the stack, apply the operation, and
148 push the result back on the stack.
150 \begin{opcodedesc}{UNARY_POSITIVE}{}
151 Implements \code{TOS = +TOS}.
152 \end{opcodedesc}
154 \begin{opcodedesc}{UNARY_NEGATIVE}{}
155 Implements \code{TOS = -TOS}.
156 \end{opcodedesc}
158 \begin{opcodedesc}{UNARY_NOT}{}
159 Implements \code{TOS = not TOS}.
160 \end{opcodedesc}
162 \begin{opcodedesc}{UNARY_CONVERT}{}
163 Implements \code{TOS = `TOS`}.
164 \end{opcodedesc}
166 \begin{opcodedesc}{UNARY_INVERT}{}
167 Implements \code{TOS = \~{}TOS}.
168 \end{opcodedesc}
170 \begin{opcodedesc}{GET_ITER}{}
171 Implements \code{TOS = iter(TOS)}.
172 \end{opcodedesc}
174 Binary operations remove the top of the stack (TOS) and the second top-most
175 stack item (TOS1) from the stack. They perform the operation, and put the
176 result back on the stack.
178 \begin{opcodedesc}{BINARY_POWER}{}
179 Implements \code{TOS = TOS1 ** TOS}.
180 \end{opcodedesc}
182 \begin{opcodedesc}{BINARY_MULTIPLY}{}
183 Implements \code{TOS = TOS1 * TOS}.
184 \end{opcodedesc}
186 \begin{opcodedesc}{BINARY_DIVIDE}{}
187 Implements \code{TOS = TOS1 / TOS} when
188 \code{from __future__ import division} is not in effect.
189 \end{opcodedesc}
191 \begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{}
192 Implements \code{TOS = TOS1 // TOS}.
193 \end{opcodedesc}
195 \begin{opcodedesc}{BINARY_TRUE_DIVIDE}{}
196 Implements \code{TOS = TOS1 / TOS} when
197 \code{from __future__ import division} is in effect.
198 \end{opcodedesc}
200 \begin{opcodedesc}{BINARY_MODULO}{}
201 Implements \code{TOS = TOS1 \%{} TOS}.
202 \end{opcodedesc}
204 \begin{opcodedesc}{BINARY_ADD}{}
205 Implements \code{TOS = TOS1 + TOS}.
206 \end{opcodedesc}
208 \begin{opcodedesc}{BINARY_SUBTRACT}{}
209 Implements \code{TOS = TOS1 - TOS}.
210 \end{opcodedesc}
212 \begin{opcodedesc}{BINARY_SUBSCR}{}
213 Implements \code{TOS = TOS1[TOS]}.
214 \end{opcodedesc}
216 \begin{opcodedesc}{BINARY_LSHIFT}{}
217 Implements \code{TOS = TOS1 <\code{}< TOS}.
218 \end{opcodedesc}
220 \begin{opcodedesc}{BINARY_RSHIFT}{}
221 Implements \code{TOS = TOS1 >\code{}> TOS}.
222 \end{opcodedesc}
224 \begin{opcodedesc}{BINARY_AND}{}
225 Implements \code{TOS = TOS1 \&\ TOS}.
226 \end{opcodedesc}
228 \begin{opcodedesc}{BINARY_XOR}{}
229 Implements \code{TOS = TOS1 \^\ TOS}.
230 \end{opcodedesc}
232 \begin{opcodedesc}{BINARY_OR}{}
233 Implements \code{TOS = TOS1 | TOS}.
234 \end{opcodedesc}
236 In-place operations are like binary operations, in that they remove TOS and
237 TOS1, and push the result back on the stack, but the operation is done
238 in-place when TOS1 supports it, and the resulting TOS may be (but does not
239 have to be) the original TOS1.
241 \begin{opcodedesc}{INPLACE_POWER}{}
242 Implements in-place \code{TOS = TOS1 ** TOS}.
243 \end{opcodedesc}
245 \begin{opcodedesc}{INPLACE_MULTIPLY}{}
246 Implements in-place \code{TOS = TOS1 * TOS}.
247 \end{opcodedesc}
249 \begin{opcodedesc}{INPLACE_DIVIDE}{}
250 Implements in-place \code{TOS = TOS1 / TOS} when
251 \code{from __future__ import division} is not in effect.
252 \end{opcodedesc}
254 \begin{opcodedesc}{INPLACE_FLOOR_DIVIDE}{}
255 Implements in-place \code{TOS = TOS1 // TOS}.
256 \end{opcodedesc}
258 \begin{opcodedesc}{INPLACE_TRUE_DIVIDE}{}
259 Implements in-place \code{TOS = TOS1 / TOS} when
260 \code{from __future__ import division} is in effect.
261 \end{opcodedesc}
263 \begin{opcodedesc}{INPLACE_MODULO}{}
264 Implements in-place \code{TOS = TOS1 \%{} TOS}.
265 \end{opcodedesc}
267 \begin{opcodedesc}{INPLACE_ADD}{}
268 Implements in-place \code{TOS = TOS1 + TOS}.
269 \end{opcodedesc}
271 \begin{opcodedesc}{INPLACE_SUBTRACT}{}
272 Implements in-place \code{TOS = TOS1 - TOS}.
273 \end{opcodedesc}
275 \begin{opcodedesc}{INPLACE_LSHIFT}{}
276 Implements in-place \code{TOS = TOS1 <\code{}< TOS}.
277 \end{opcodedesc}
279 \begin{opcodedesc}{INPLACE_RSHIFT}{}
280 Implements in-place \code{TOS = TOS1 >\code{}> TOS}.
281 \end{opcodedesc}
283 \begin{opcodedesc}{INPLACE_AND}{}
284 Implements in-place \code{TOS = TOS1 \&\ TOS}.
285 \end{opcodedesc}
287 \begin{opcodedesc}{INPLACE_XOR}{}
288 Implements in-place \code{TOS = TOS1 \^\ TOS}.
289 \end{opcodedesc}
291 \begin{opcodedesc}{INPLACE_OR}{}
292 Implements in-place \code{TOS = TOS1 | TOS}.
293 \end{opcodedesc}
295 The slice opcodes take up to three parameters.
297 \begin{opcodedesc}{SLICE+0}{}
298 Implements \code{TOS = TOS[:]}.
299 \end{opcodedesc}
301 \begin{opcodedesc}{SLICE+1}{}
302 Implements \code{TOS = TOS1[TOS:]}.
303 \end{opcodedesc}
305 \begin{opcodedesc}{SLICE+2}{}
306 Implements \code{TOS = TOS1[:TOS]}.
307 \end{opcodedesc}
309 \begin{opcodedesc}{SLICE+3}{}
310 Implements \code{TOS = TOS2[TOS1:TOS]}.
311 \end{opcodedesc}
313 Slice assignment needs even an additional parameter. As any statement,
314 they put nothing on the stack.
316 \begin{opcodedesc}{STORE_SLICE+0}{}
317 Implements \code{TOS[:] = TOS1}.
318 \end{opcodedesc}
320 \begin{opcodedesc}{STORE_SLICE+1}{}
321 Implements \code{TOS1[TOS:] = TOS2}.
322 \end{opcodedesc}
324 \begin{opcodedesc}{STORE_SLICE+2}{}
325 Implements \code{TOS1[:TOS] = TOS2}.
326 \end{opcodedesc}
328 \begin{opcodedesc}{STORE_SLICE+3}{}
329 Implements \code{TOS2[TOS1:TOS] = TOS3}.
330 \end{opcodedesc}
332 \begin{opcodedesc}{DELETE_SLICE+0}{}
333 Implements \code{del TOS[:]}.
334 \end{opcodedesc}
336 \begin{opcodedesc}{DELETE_SLICE+1}{}
337 Implements \code{del TOS1[TOS:]}.
338 \end{opcodedesc}
340 \begin{opcodedesc}{DELETE_SLICE+2}{}
341 Implements \code{del TOS1[:TOS]}.
342 \end{opcodedesc}
344 \begin{opcodedesc}{DELETE_SLICE+3}{}
345 Implements \code{del TOS2[TOS1:TOS]}.
346 \end{opcodedesc}
348 \begin{opcodedesc}{STORE_SUBSCR}{}
349 Implements \code{TOS1[TOS] = TOS2}.
350 \end{opcodedesc}
352 \begin{opcodedesc}{DELETE_SUBSCR}{}
353 Implements \code{del TOS1[TOS]}.
354 \end{opcodedesc}
356 Miscellaneous opcodes.
358 \begin{opcodedesc}{PRINT_EXPR}{}
359 Implements the expression statement for the interactive mode. TOS is
360 removed from the stack and printed. In non-interactive mode, an
361 expression statement is terminated with \code{POP_STACK}.
362 \end{opcodedesc}
364 \begin{opcodedesc}{PRINT_ITEM}{}
365 Prints TOS to the file-like object bound to \code{sys.stdout}. There
366 is one such instruction for each item in the \keyword{print} statement.
367 \end{opcodedesc}
369 \begin{opcodedesc}{PRINT_ITEM_TO}{}
370 Like \code{PRINT_ITEM}, but prints the item second from TOS to the
371 file-like object at TOS. This is used by the extended print statement.
372 \end{opcodedesc}
374 \begin{opcodedesc}{PRINT_NEWLINE}{}
375 Prints a new line on \code{sys.stdout}. This is generated as the
376 last operation of a \keyword{print} statement, unless the statement
377 ends with a comma.
378 \end{opcodedesc}
380 \begin{opcodedesc}{PRINT_NEWLINE_TO}{}
381 Like \code{PRINT_NEWLINE}, but prints the new line on the file-like
382 object on the TOS. This is used by the extended print statement.
383 \end{opcodedesc}
385 \begin{opcodedesc}{BREAK_LOOP}{}
386 Terminates a loop due to a \keyword{break} statement.
387 \end{opcodedesc}
389 \begin{opcodedesc}{CONTINUE_LOOP}{target}
390 Continues a loop due to a \keyword{continue} statement. \var{target}
391 is the address to jump to (which should be a \code{FOR_ITER}
392 instruction).
393 \end{opcodedesc}
395 \begin{opcodedesc}{LOAD_LOCALS}{}
396 Pushes a reference to the locals of the current scope on the stack.
397 This is used in the code for a class definition: After the class body
398 is evaluated, the locals are passed to the class definition.
399 \end{opcodedesc}
401 \begin{opcodedesc}{RETURN_VALUE}{}
402 Returns with TOS to the caller of the function.
403 \end{opcodedesc}
405 \begin{opcodedesc}{YIELD_VALUE}{}
406 Pops \code{TOS} and yields it from a generator.
407 \end{opcodedesc}
409 \begin{opcodedesc}{IMPORT_STAR}{}
410 Loads all symbols not starting with \character{_} directly from the module TOS
411 to the local namespace. The module is popped after loading all names.
412 This opcode implements \code{from module import *}.
413 \end{opcodedesc}
415 \begin{opcodedesc}{EXEC_STMT}{}
416 Implements \code{exec TOS2,TOS1,TOS}. The compiler fills
417 missing optional parameters with \code{None}.
418 \end{opcodedesc}
420 \begin{opcodedesc}{POP_BLOCK}{}
421 Removes one block from the block stack. Per frame, there is a
422 stack of blocks, denoting nested loops, try statements, and such.
423 \end{opcodedesc}
425 \begin{opcodedesc}{END_FINALLY}{}
426 Terminates a \keyword{finally} clause. The interpreter recalls
427 whether the exception has to be re-raised, or whether the function
428 returns, and continues with the outer-next block.
429 \end{opcodedesc}
431 \begin{opcodedesc}{BUILD_CLASS}{}
432 Creates a new class object. TOS is the methods dictionary, TOS1
433 the tuple of the names of the base classes, and TOS2 the class name.
434 \end{opcodedesc}
436 All of the following opcodes expect arguments. An argument is two
437 bytes, with the more significant byte last.
439 \begin{opcodedesc}{STORE_NAME}{namei}
440 Implements \code{name = TOS}. \var{namei} is the index of \var{name}
441 in the attribute \member{co_names} of the code object.
442 The compiler tries to use \code{STORE_LOCAL} or \code{STORE_GLOBAL}
443 if possible.
444 \end{opcodedesc}
446 \begin{opcodedesc}{DELETE_NAME}{namei}
447 Implements \code{del name}, where \var{namei} is the index into
448 \member{co_names} attribute of the code object.
449 \end{opcodedesc}
451 \begin{opcodedesc}{UNPACK_SEQUENCE}{count}
452 Unpacks TOS into \var{count} individual values, which are put onto
453 the stack right-to-left.
454 \end{opcodedesc}
456 %\begin{opcodedesc}{UNPACK_LIST}{count}
457 %This opcode is obsolete.
458 %\end{opcodedesc}
460 %\begin{opcodedesc}{UNPACK_ARG}{count}
461 %This opcode is obsolete.
462 %\end{opcodedesc}
464 \begin{opcodedesc}{DUP_TOPX}{count}
465 Duplicate \var{count} items, keeping them in the same order. Due to
466 implementation limits, \var{count} should be between 1 and 5 inclusive.
467 \end{opcodedesc}
469 \begin{opcodedesc}{STORE_ATTR}{namei}
470 Implements \code{TOS.name = TOS1}, where \var{namei} is the index
471 of name in \member{co_names}.
472 \end{opcodedesc}
474 \begin{opcodedesc}{DELETE_ATTR}{namei}
475 Implements \code{del TOS.name}, using \var{namei} as index into
476 \member{co_names}.
477 \end{opcodedesc}
479 \begin{opcodedesc}{STORE_GLOBAL}{namei}
480 Works as \code{STORE_NAME}, but stores the name as a global.
481 \end{opcodedesc}
483 \begin{opcodedesc}{DELETE_GLOBAL}{namei}
484 Works as \code{DELETE_NAME}, but deletes a global name.
485 \end{opcodedesc}
487 %\begin{opcodedesc}{UNPACK_VARARG}{argc}
488 %This opcode is obsolete.
489 %\end{opcodedesc}
491 \begin{opcodedesc}{LOAD_CONST}{consti}
492 Pushes \samp{co_consts[\var{consti}]} onto the stack.
493 \end{opcodedesc}
495 \begin{opcodedesc}{LOAD_NAME}{namei}
496 Pushes the value associated with \samp{co_names[\var{namei}]} onto the stack.
497 \end{opcodedesc}
499 \begin{opcodedesc}{BUILD_TUPLE}{count}
500 Creates a tuple consuming \var{count} items from the stack, and pushes
501 the resulting tuple onto the stack.
502 \end{opcodedesc}
504 \begin{opcodedesc}{BUILD_LIST}{count}
505 Works as \code{BUILD_TUPLE}, but creates a list.
506 \end{opcodedesc}
508 \begin{opcodedesc}{BUILD_MAP}{zero}
509 Pushes a new empty dictionary object onto the stack. The argument is
510 ignored and set to zero by the compiler.
511 \end{opcodedesc}
513 \begin{opcodedesc}{LOAD_ATTR}{namei}
514 Replaces TOS with \code{getattr(TOS, co_names[\var{namei}]}.
515 \end{opcodedesc}
517 \begin{opcodedesc}{COMPARE_OP}{opname}
518 Performs a Boolean operation. The operation name can be found
519 in \code{cmp_op[\var{opname}]}.
520 \end{opcodedesc}
522 \begin{opcodedesc}{IMPORT_NAME}{namei}
523 Imports the module \code{co_names[\var{namei}]}. The module object is
524 pushed onto the stack. The current namespace is not affected: for a
525 proper import statement, a subsequent \code{STORE_FAST} instruction
526 modifies the namespace.
527 \end{opcodedesc}
529 \begin{opcodedesc}{IMPORT_FROM}{namei}
530 Loads the attribute \code{co_names[\var{namei}]} from the module found in
531 TOS. The resulting object is pushed onto the stack, to be subsequently
532 stored by a \code{STORE_FAST} instruction.
533 \end{opcodedesc}
535 \begin{opcodedesc}{JUMP_FORWARD}{delta}
536 Increments byte code counter by \var{delta}.
537 \end{opcodedesc}
539 \begin{opcodedesc}{JUMP_IF_TRUE}{delta}
540 If TOS is true, increment the byte code counter by \var{delta}. TOS is
541 left on the stack.
542 \end{opcodedesc}
544 \begin{opcodedesc}{JUMP_IF_FALSE}{delta}
545 If TOS is false, increment the byte code counter by \var{delta}. TOS
546 is not changed.
547 \end{opcodedesc}
549 \begin{opcodedesc}{JUMP_ABSOLUTE}{target}
550 Set byte code counter to \var{target}.
551 \end{opcodedesc}
553 \begin{opcodedesc}{FOR_ITER}{delta}
554 \code{TOS} is an iterator. Call its \method{next()} method. If this
555 yields a new value, push it on the stack (leaving the iterator below
556 it). If the iterator indicates it is exhausted \code{TOS} is
557 popped, and the byte code counter is incremented by \var{delta}.
558 \end{opcodedesc}
560 %\begin{opcodedesc}{FOR_LOOP}{delta}
561 %This opcode is obsolete.
562 %\end{opcodedesc}
564 %\begin{opcodedesc}{LOAD_LOCAL}{namei}
565 %This opcode is obsolete.
566 %\end{opcodedesc}
568 \begin{opcodedesc}{LOAD_GLOBAL}{namei}
569 Loads the global named \code{co_names[\var{namei}]} onto the stack.
570 \end{opcodedesc}
572 %\begin{opcodedesc}{SET_FUNC_ARGS}{argc}
573 %This opcode is obsolete.
574 %\end{opcodedesc}
576 \begin{opcodedesc}{SETUP_LOOP}{delta}
577 Pushes a block for a loop onto the block stack. The block spans
578 from the current instruction with a size of \var{delta} bytes.
579 \end{opcodedesc}
581 \begin{opcodedesc}{SETUP_EXCEPT}{delta}
582 Pushes a try block from a try-except clause onto the block stack.
583 \var{delta} points to the first except block.
584 \end{opcodedesc}
586 \begin{opcodedesc}{SETUP_FINALLY}{delta}
587 Pushes a try block from a try-except clause onto the block stack.
588 \var{delta} points to the finally block.
589 \end{opcodedesc}
591 \begin{opcodedesc}{LOAD_FAST}{var_num}
592 Pushes a reference to the local \code{co_varnames[\var{var_num}]} onto
593 the stack.
594 \end{opcodedesc}
596 \begin{opcodedesc}{STORE_FAST}{var_num}
597 Stores TOS into the local \code{co_varnames[\var{var_num}]}.
598 \end{opcodedesc}
600 \begin{opcodedesc}{DELETE_FAST}{var_num}
601 Deletes local \code{co_varnames[\var{var_num}]}.
602 \end{opcodedesc}
604 \begin{opcodedesc}{LOAD_CLOSURE}{i}
605 Pushes a reference to the cell contained in slot \var{i} of the
606 cell and free variable storage. The name of the variable is
607 \code{co_cellvars[\var{i}]} if \var{i} is less than the length of
608 \var{co_cellvars}. Otherwise it is
609 \code{co_freevars[\var{i} - len(co_cellvars)]}.
610 \end{opcodedesc}
612 \begin{opcodedesc}{LOAD_DEREF}{i}
613 Loads the cell contained in slot \var{i} of the cell and free variable
614 storage. Pushes a reference to the object the cell contains on the
615 stack.
616 \end{opcodedesc}
618 \begin{opcodedesc}{STORE_DEREF}{i}
619 Stores TOS into the cell contained in slot \var{i} of the cell and
620 free variable storage.
621 \end{opcodedesc}
623 \begin{opcodedesc}{SET_LINENO}{lineno}
624 This opcode is obsolete.
625 \end{opcodedesc}
627 \begin{opcodedesc}{RAISE_VARARGS}{argc}
628 Raises an exception. \var{argc} indicates the number of parameters
629 to the raise statement, ranging from 0 to 3. The handler will find
630 the traceback as TOS2, the parameter as TOS1, and the exception
631 as TOS.
632 \end{opcodedesc}
634 \begin{opcodedesc}{CALL_FUNCTION}{argc}
635 Calls a function. The low byte of \var{argc} indicates the number of
636 positional parameters, the high byte the number of keyword parameters.
637 On the stack, the opcode finds the keyword parameters first. For each
638 keyword argument, the value is on top of the key. Below the keyword
639 parameters, the positional parameters are on the stack, with the
640 right-most parameter on top. Below the parameters, the function object
641 to call is on the stack.
642 \end{opcodedesc}
644 \begin{opcodedesc}{MAKE_FUNCTION}{argc}
645 Pushes a new function object on the stack. TOS is the code associated
646 with the function. The function object is defined to have \var{argc}
647 default parameters, which are found below TOS.
648 \end{opcodedesc}
650 \begin{opcodedesc}{MAKE_CLOSURE}{argc}
651 Creates a new function object, sets its \var{func_closure} slot, and
652 pushes it on the stack. TOS is the code associated with the function.
653 If the code object has N free variables, the next N items on the stack
654 are the cells for these variables. The function also has \var{argc}
655 default parameters, where are found before the cells.
656 \end{opcodedesc}
658 \begin{opcodedesc}{BUILD_SLICE}{argc}
659 Pushes a slice object on the stack. \var{argc} must be 2 or 3. If it
660 is 2, \code{slice(TOS1, TOS)} is pushed; if it is 3,
661 \code{slice(TOS2, TOS1, TOS)} is pushed.
662 See the \code{slice()}\bifuncindex{slice} built-in function for more
663 information.
664 \end{opcodedesc}
666 \begin{opcodedesc}{EXTENDED_ARG}{ext}
667 Prefixes any opcode which has an argument too big to fit into the
668 default two bytes. \var{ext} holds two additional bytes which, taken
669 together with the subsequent opcode's argument, comprise a four-byte
670 argument, \var{ext} being the two most-significant bytes.
671 \end{opcodedesc}
673 \begin{opcodedesc}{CALL_FUNCTION_VAR}{argc}
674 Calls a function. \var{argc} is interpreted as in \code{CALL_FUNCTION}.
675 The top element on the stack contains the variable argument list, followed
676 by keyword and positional arguments.
677 \end{opcodedesc}
679 \begin{opcodedesc}{CALL_FUNCTION_KW}{argc}
680 Calls a function. \var{argc} is interpreted as in \code{CALL_FUNCTION}.
681 The top element on the stack contains the keyword arguments dictionary,
682 followed by explicit keyword and positional arguments.
683 \end{opcodedesc}
685 \begin{opcodedesc}{CALL_FUNCTION_VAR_KW}{argc}
686 Calls a function. \var{argc} is interpreted as in
687 \code{CALL_FUNCTION}. The top element on the stack contains the
688 keyword arguments dictionary, followed by the variable-arguments
689 tuple, followed by explicit keyword and positional arguments.
690 \end{opcodedesc}