- Got rid of newmodule.c
[python/dscho.git] / Doc / lib / libdis.tex
blob90f83a3624f9615e3103ff3318f143f1ebdd504e
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 0 SET_LINENO 1
28 3 SET_LINENO 2
29 6 LOAD_GLOBAL 0 (len)
30 9 LOAD_FAST 0 (alist)
31 12 CALL_FUNCTION 1
32 15 RETURN_VALUE
33 16 LOAD_CONST 0 (None)
34 19 RETURN_VALUE
35 \end{verbatim}
37 The \module{dis} module defines the following functions and constants:
39 \begin{funcdesc}{dis}{\optional{bytesource}}
40 Disassemble the \var{bytesource} object. \var{bytesource} can denote
41 either a class, a method, a function, or a code object. 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 current instruction, indicated as \samp{-->},
59 \item a labelled instruction, indicated with \samp{>\code{>}},
60 \item the address of the instruction,
61 \item the operation code name,
62 \item operation parameters, and
63 \item interpretation of the parameters in parentheses.
64 \end{enumerate}
66 The parameter interpretation recognizes local and global
67 variable names, constant values, branch targets, and compare
68 operators.
69 \end{funcdesc}
71 \begin{funcdesc}{disco}{code\optional{, lasti}}
72 A synonym for disassemble. It is more convenient to type, and kept
73 for compatibility with earlier Python releases.
74 \end{funcdesc}
76 \begin{datadesc}{opname}
77 Sequence of operation names, indexable using the byte code.
78 \end{datadesc}
80 \begin{datadesc}{cmp_op}
81 Sequence of all compare operation names.
82 \end{datadesc}
84 \begin{datadesc}{hasconst}
85 Sequence of byte codes that have a constant parameter.
86 \end{datadesc}
88 \begin{datadesc}{hasfree}
89 Sequence of byte codes that access a free variable.
90 \end{datadesc}
92 \begin{datadesc}{hasname}
93 Sequence of byte codes that access an attribute by name.
94 \end{datadesc}
96 \begin{datadesc}{hasjrel}
97 Sequence of byte codes that have a relative jump target.
98 \end{datadesc}
100 \begin{datadesc}{hasjabs}
101 Sequence of byte codes that have an absolute jump target.
102 \end{datadesc}
104 \begin{datadesc}{haslocal}
105 Sequence of byte codes that access a local variable.
106 \end{datadesc}
108 \begin{datadesc}{hascompare}
109 Sequence of byte codes of Boolean operations.
110 \end{datadesc}
112 \subsection{Python Byte Code Instructions}
113 \label{bytecodes}
115 The Python compiler currently generates the following byte code
116 instructions.
118 \setindexsubitem{(byte code insns)}
120 \begin{opcodedesc}{STOP_CODE}{}
121 Indicates end-of-code to the compiler, not used by the interpreter.
122 \end{opcodedesc}
124 \begin{opcodedesc}{POP_TOP}{}
125 Removes the top-of-stack (TOS) item.
126 \end{opcodedesc}
128 \begin{opcodedesc}{ROT_TWO}{}
129 Swaps the two top-most stack items.
130 \end{opcodedesc}
132 \begin{opcodedesc}{ROT_THREE}{}
133 Lifts second and third stack item one position up, moves top down
134 to position three.
135 \end{opcodedesc}
137 \begin{opcodedesc}{ROT_FOUR}{}
138 Lifts second, third and forth stack item one position up, moves top down to
139 position four.
140 \end{opcodedesc}
142 \begin{opcodedesc}{DUP_TOP}{}
143 Duplicates the reference on top of the stack.
144 \end{opcodedesc}
146 Unary Operations take the top of the stack, apply the operation, and
147 push the result back on the stack.
149 \begin{opcodedesc}{UNARY_POSITIVE}{}
150 Implements \code{TOS = +TOS}.
151 \end{opcodedesc}
153 \begin{opcodedesc}{UNARY_NEGATIVE}{}
154 Implements \code{TOS = -TOS}.
155 \end{opcodedesc}
157 \begin{opcodedesc}{UNARY_NOT}{}
158 Implements \code{TOS = not TOS}.
159 \end{opcodedesc}
161 \begin{opcodedesc}{UNARY_CONVERT}{}
162 Implements \code{TOS = `TOS`}.
163 \end{opcodedesc}
165 \begin{opcodedesc}{UNARY_INVERT}{}
166 Implements \code{TOS = \~{}TOS}.
167 \end{opcodedesc}
169 \begin{opcodedesc}{GET_ITER}{}
170 Implements \code{TOS = iter(TOS)}.
171 \end{opcodedesc}
173 Binary operations remove the top of the stack (TOS) and the second top-most
174 stack item (TOS1) from the stack. They perform the operation, and put the
175 result back on the stack.
177 \begin{opcodedesc}{BINARY_POWER}{}
178 Implements \code{TOS = TOS1 ** TOS}.
179 \end{opcodedesc}
181 \begin{opcodedesc}{BINARY_MULTIPLY}{}
182 Implements \code{TOS = TOS1 * TOS}.
183 \end{opcodedesc}
185 \begin{opcodedesc}{BINARY_DIVIDE}{}
186 Implements \code{TOS = TOS1 / TOS} when
187 \code{from __future__ import division} is not in effect.
188 \end{opcodedesc}
190 \begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{}
191 Implements \code{TOS = TOS1 // TOS}.
192 \end{opcodedesc}
194 \begin{opcodedesc}{BINARY_TRUE_DIVIDE}{}
195 Implements \code{TOS = TOS1 / TOS} when
196 \code{from __future__ import division} is in effect.
197 \end{opcodedesc}
199 \begin{opcodedesc}{BINARY_MODULO}{}
200 Implements \code{TOS = TOS1 \%{} TOS}.
201 \end{opcodedesc}
203 \begin{opcodedesc}{BINARY_ADD}{}
204 Implements \code{TOS = TOS1 + TOS}.
205 \end{opcodedesc}
207 \begin{opcodedesc}{BINARY_SUBTRACT}{}
208 Implements \code{TOS = TOS1 - TOS}.
209 \end{opcodedesc}
211 \begin{opcodedesc}{BINARY_SUBSCR}{}
212 Implements \code{TOS = TOS1[TOS]}.
213 \end{opcodedesc}
215 \begin{opcodedesc}{BINARY_LSHIFT}{}
216 Implements \code{TOS = TOS1 <\code{}< TOS}.
217 \end{opcodedesc}
219 \begin{opcodedesc}{BINARY_RSHIFT}{}
220 Implements \code{TOS = TOS1 >\code{}> TOS}.
221 \end{opcodedesc}
223 \begin{opcodedesc}{BINARY_AND}{}
224 Implements \code{TOS = TOS1 \&\ TOS}.
225 \end{opcodedesc}
227 \begin{opcodedesc}{BINARY_XOR}{}
228 Implements \code{TOS = TOS1 \^\ TOS}.
229 \end{opcodedesc}
231 \begin{opcodedesc}{BINARY_OR}{}
232 Implements \code{TOS = TOS1 | TOS}.
233 \end{opcodedesc}
235 In-place operations are like binary operations, in that they remove TOS and
236 TOS1, and push the result back on the stack, but the operation is done
237 in-place when TOS1 supports it, and the resulting TOS may be (but does not
238 have to be) the original TOS1.
240 \begin{opcodedesc}{INPLACE_POWER}{}
241 Implements in-place \code{TOS = TOS1 ** TOS}.
242 \end{opcodedesc}
244 \begin{opcodedesc}{INPLACE_MULTIPLY}{}
245 Implements in-place \code{TOS = TOS1 * TOS}.
246 \end{opcodedesc}
248 \begin{opcodedesc}{INPLACE_DIVIDE}{}
249 Implements in-place \code{TOS = TOS1 / TOS} when
250 \code{from __future__ import division} is not in effect.
251 \end{opcodedesc}
253 \begin{opcodedesc}{INPLACE_FLOOR_DIVIDE}{}
254 Implements in-place \code{TOS = TOS1 // TOS}.
255 \end{opcodedesc}
257 \begin{opcodedesc}{INPLACE_TRUE_DIVIDE}{}
258 Implements in-place \code{TOS = TOS1 / TOS} when
259 \code{from __future__ import division} is in effect.
260 \end{opcodedesc}
262 \begin{opcodedesc}{INPLACE_MODULO}{}
263 Implements in-place \code{TOS = TOS1 \%{} TOS}.
264 \end{opcodedesc}
266 \begin{opcodedesc}{INPLACE_ADD}{}
267 Implements in-place \code{TOS = TOS1 + TOS}.
268 \end{opcodedesc}
270 \begin{opcodedesc}{INPLACE_SUBTRACT}{}
271 Implements in-place \code{TOS = TOS1 - TOS}.
272 \end{opcodedesc}
274 \begin{opcodedesc}{INPLACE_LSHIFT}{}
275 Implements in-place \code{TOS = TOS1 <\code{}< TOS}.
276 \end{opcodedesc}
278 \begin{opcodedesc}{INPLACE_RSHIFT}{}
279 Implements in-place \code{TOS = TOS1 >\code{}> TOS}.
280 \end{opcodedesc}
282 \begin{opcodedesc}{INPLACE_AND}{}
283 Implements in-place \code{TOS = TOS1 \&\ TOS}.
284 \end{opcodedesc}
286 \begin{opcodedesc}{INPLACE_XOR}{}
287 Implements in-place \code{TOS = TOS1 \^\ TOS}.
288 \end{opcodedesc}
290 \begin{opcodedesc}{INPLACE_OR}{}
291 Implements in-place \code{TOS = TOS1 | TOS}.
292 \end{opcodedesc}
294 The slice opcodes take up to three parameters.
296 \begin{opcodedesc}{SLICE+0}{}
297 Implements \code{TOS = TOS[:]}.
298 \end{opcodedesc}
300 \begin{opcodedesc}{SLICE+1}{}
301 Implements \code{TOS = TOS1[TOS:]}.
302 \end{opcodedesc}
304 \begin{opcodedesc}{SLICE+2}{}
305 Implements \code{TOS = TOS1[:TOS1]}.
306 \end{opcodedesc}
308 \begin{opcodedesc}{SLICE+3}{}
309 Implements \code{TOS = TOS2[TOS1:TOS]}.
310 \end{opcodedesc}
312 Slice assignment needs even an additional parameter. As any statement,
313 they put nothing on the stack.
315 \begin{opcodedesc}{STORE_SLICE+0}{}
316 Implements \code{TOS[:] = TOS1}.
317 \end{opcodedesc}
319 \begin{opcodedesc}{STORE_SLICE+1}{}
320 Implements \code{TOS1[TOS:] = TOS2}.
321 \end{opcodedesc}
323 \begin{opcodedesc}{STORE_SLICE+2}{}
324 Implements \code{TOS1[:TOS] = TOS2}.
325 \end{opcodedesc}
327 \begin{opcodedesc}{STORE_SLICE+3}{}
328 Implements \code{TOS2[TOS1:TOS] = TOS3}.
329 \end{opcodedesc}
331 \begin{opcodedesc}{DELETE_SLICE+0}{}
332 Implements \code{del TOS[:]}.
333 \end{opcodedesc}
335 \begin{opcodedesc}{DELETE_SLICE+1}{}
336 Implements \code{del TOS1[TOS:]}.
337 \end{opcodedesc}
339 \begin{opcodedesc}{DELETE_SLICE+2}{}
340 Implements \code{del TOS1[:TOS]}.
341 \end{opcodedesc}
343 \begin{opcodedesc}{DELETE_SLICE+3}{}
344 Implements \code{del TOS2[TOS1:TOS]}.
345 \end{opcodedesc}
347 \begin{opcodedesc}{STORE_SUBSCR}{}
348 Implements \code{TOS1[TOS] = TOS2}.
349 \end{opcodedesc}
351 \begin{opcodedesc}{DELETE_SUBSCR}{}
352 Implements \code{del TOS1[TOS]}.
353 \end{opcodedesc}
355 Miscellaneous opcodes.
357 \begin{opcodedesc}{PRINT_EXPR}{}
358 Implements the expression statement for the interactive mode. TOS is
359 removed from the stack and printed. In non-interactive mode, an
360 expression statement is terminated with \code{POP_STACK}.
361 \end{opcodedesc}
363 \begin{opcodedesc}{PRINT_ITEM}{}
364 Prints TOS to the file-like object bound to \code{sys.stdout}. There
365 is one such instruction for each item in the \keyword{print} statement.
366 \end{opcodedesc}
368 \begin{opcodedesc}{PRINT_ITEM_TO}{}
369 Like \code{PRINT_ITEM}, but prints the item second from TOS to the
370 file-like object at TOS. This is used by the extended print statement.
371 \end{opcodedesc}
373 \begin{opcodedesc}{PRINT_NEWLINE}{}
374 Prints a new line on \code{sys.stdout}. This is generated as the
375 last operation of a \keyword{print} statement, unless the statement
376 ends with a comma.
377 \end{opcodedesc}
379 \begin{opcodedesc}{PRINT_NEWLINE_TO}{}
380 Like \code{PRINT_NEWLINE}, but prints the new line on the file-like
381 object on the TOS. This is used by the extended print statement.
382 \end{opcodedesc}
384 \begin{opcodedesc}{BREAK_LOOP}{}
385 Terminates a loop due to a \keyword{break} statement.
386 \end{opcodedesc}
388 \begin{opcodedesc}{CONTINUE_LOOP}{target}
389 Continues a loop due to a \keyword{continue} statement. \var{target}
390 is the address to jump to (which should be a \code{FOR_ITER}
391 instruction).
392 \end{opcodedesc}
394 \begin{opcodedesc}{LOAD_LOCALS}{}
395 Pushes a reference to the locals of the current scope on the stack.
396 This is used in the code for a class definition: After the class body
397 is evaluated, the locals are passed to the class definition.
398 \end{opcodedesc}
400 \begin{opcodedesc}{RETURN_VALUE}{}
401 Returns with TOS to the caller of the function.
402 \end{opcodedesc}
404 \begin{opcodedesc}{YIELD_VALUE}{}
405 Pops \code{TOS} and yields it from a generator.
406 \end{opcodedesc}
408 \begin{opcodedesc}{IMPORT_STAR}{}
409 Loads all symbols not starting with \character{_} directly from the module TOS
410 to the local namespace. The module is popped after loading all names.
411 This opcode implements \code{from module import *}.
412 \end{opcodedesc}
414 \begin{opcodedesc}{EXEC_STMT}{}
415 Implements \code{exec TOS2,TOS1,TOS}. The compiler fills
416 missing optional parameters with \code{None}.
417 \end{opcodedesc}
419 \begin{opcodedesc}{POP_BLOCK}{}
420 Removes one block from the block stack. Per frame, there is a
421 stack of blocks, denoting nested loops, try statements, and such.
422 \end{opcodedesc}
424 \begin{opcodedesc}{END_FINALLY}{}
425 Terminates a \keyword{finally} clause. The interpreter recalls
426 whether the exception has to be re-raised, or whether the function
427 returns, and continues with the outer-next block.
428 \end{opcodedesc}
430 \begin{opcodedesc}{BUILD_CLASS}{}
431 Creates a new class object. TOS is the methods dictionary, TOS1
432 the tuple of the names of the base classes, and TOS2 the class name.
433 \end{opcodedesc}
435 All of the following opcodes expect arguments. An argument is two
436 bytes, with the more significant byte last.
438 \begin{opcodedesc}{STORE_NAME}{namei}
439 Implements \code{name = TOS}. \var{namei} is the index of \var{name}
440 in the attribute \member{co_names} of the code object.
441 The compiler tries to use \code{STORE_LOCAL} or \code{STORE_GLOBAL}
442 if possible.
443 \end{opcodedesc}
445 \begin{opcodedesc}{DELETE_NAME}{namei}
446 Implements \code{del name}, where \var{namei} is the index into
447 \member{co_names} attribute of the code object.
448 \end{opcodedesc}
450 \begin{opcodedesc}{UNPACK_SEQUENCE}{count}
451 Unpacks TOS into \var{count} individual values, which are put onto
452 the stack right-to-left.
453 \end{opcodedesc}
455 %\begin{opcodedesc}{UNPACK_LIST}{count}
456 %This opcode is obsolete.
457 %\end{opcodedesc}
459 %\begin{opcodedesc}{UNPACK_ARG}{count}
460 %This opcode is obsolete.
461 %\end{opcodedesc}
463 \begin{opcodedesc}{DUP_TOPX}{count}
464 Duplicate \var{count} items, keeping them in the same order. Due to
465 implementation limits, \var{count} should be between 1 and 5 inclusive.
466 \end{opcodedesc}
468 \begin{opcodedesc}{STORE_ATTR}{namei}
469 Implements \code{TOS.name = TOS1}, where \var{namei} is the index
470 of name in \member{co_names}.
471 \end{opcodedesc}
473 \begin{opcodedesc}{DELETE_ATTR}{namei}
474 Implements \code{del TOS.name}, using \var{namei} as index into
475 \member{co_names}.
476 \end{opcodedesc}
478 \begin{opcodedesc}{STORE_GLOBAL}{namei}
479 Works as \code{STORE_NAME}, but stores the name as a global.
480 \end{opcodedesc}
482 \begin{opcodedesc}{DELETE_GLOBAL}{namei}
483 Works as \code{DELETE_NAME}, but deletes a global name.
484 \end{opcodedesc}
486 %\begin{opcodedesc}{UNPACK_VARARG}{argc}
487 %This opcode is obsolete.
488 %\end{opcodedesc}
490 \begin{opcodedesc}{LOAD_CONST}{consti}
491 Pushes \samp{co_consts[\var{consti}]} onto the stack.
492 \end{opcodedesc}
494 \begin{opcodedesc}{LOAD_NAME}{namei}
495 Pushes the value associated with \samp{co_names[\var{namei}]} onto the stack.
496 \end{opcodedesc}
498 \begin{opcodedesc}{BUILD_TUPLE}{count}
499 Creates a tuple consuming \var{count} items from the stack, and pushes
500 the resulting tuple onto the stack.
501 \end{opcodedesc}
503 \begin{opcodedesc}{BUILD_LIST}{count}
504 Works as \code{BUILD_TUPLE}, but creates a list.
505 \end{opcodedesc}
507 \begin{opcodedesc}{BUILD_MAP}{zero}
508 Pushes a new empty dictionary object onto the stack. The argument is
509 ignored and set to zero by the compiler.
510 \end{opcodedesc}
512 \begin{opcodedesc}{LOAD_ATTR}{namei}
513 Replaces TOS with \code{getattr(TOS, co_names[\var{namei}]}.
514 \end{opcodedesc}
516 \begin{opcodedesc}{COMPARE_OP}{opname}
517 Performs a Boolean operation. The operation name can be found
518 in \code{cmp_op[\var{opname}]}.
519 \end{opcodedesc}
521 \begin{opcodedesc}{IMPORT_NAME}{namei}
522 Imports the module \code{co_names[\var{namei}]}. The module object is
523 pushed onto the stack. The current namespace is not affected: for a
524 proper import statement, a subsequent \code{STORE_FAST} instruction
525 modifies the namespace.
526 \end{opcodedesc}
528 \begin{opcodedesc}{IMPORT_FROM}{namei}
529 Loads the attribute \code{co_names[\var{namei}]} from the module found in
530 TOS. The resulting object is pushed onto the stack, to be subsequently
531 stored by a \code{STORE_FAST} instruction.
532 \end{opcodedesc}
534 \begin{opcodedesc}{JUMP_FORWARD}{delta}
535 Increments byte code counter by \var{delta}.
536 \end{opcodedesc}
538 \begin{opcodedesc}{JUMP_IF_TRUE}{delta}
539 If TOS is true, increment the byte code counter by \var{delta}. TOS is
540 left on the stack.
541 \end{opcodedesc}
543 \begin{opcodedesc}{JUMP_IF_FALSE}{delta}
544 If TOS is false, increment the byte code counter by \var{delta}. TOS
545 is not changed.
546 \end{opcodedesc}
548 \begin{opcodedesc}{JUMP_ABSOLUTE}{target}
549 Set byte code counter to \var{target}.
550 \end{opcodedesc}
552 \begin{opcodedesc}{FOR_ITER}{delta}
553 \code{TOS} is an iterator. Call its \method{next()} method. If this
554 yields a new value, push it on the stack (leaving the iterator below
555 it). If the iterator indicates it is exhausted \code{TOS} is
556 popped, and the byte code counter is incremented by \var{delta}.
557 \end{opcodedesc}
559 %\begin{opcodedesc}{FOR_LOOP}{delta}
560 %This opcode is obsolete.
561 %\end{opcodedesc}
563 %\begin{opcodedesc}{LOAD_LOCAL}{namei}
564 %This opcode is obsolete.
565 %\end{opcodedesc}
567 \begin{opcodedesc}{LOAD_GLOBAL}{namei}
568 Loads the global named \code{co_names[\var{namei}]} onto the stack.
569 \end{opcodedesc}
571 %\begin{opcodedesc}{SET_FUNC_ARGS}{argc}
572 %This opcode is obsolete.
573 %\end{opcodedesc}
575 \begin{opcodedesc}{SETUP_LOOP}{delta}
576 Pushes a block for a loop onto the block stack. The block spans
577 from the current instruction with a size of \var{delta} bytes.
578 \end{opcodedesc}
580 \begin{opcodedesc}{SETUP_EXCEPT}{delta}
581 Pushes a try block from a try-except clause onto the block stack.
582 \var{delta} points to the first except block.
583 \end{opcodedesc}
585 \begin{opcodedesc}{SETUP_FINALLY}{delta}
586 Pushes a try block from a try-except clause onto the block stack.
587 \var{delta} points to the finally block.
588 \end{opcodedesc}
590 \begin{opcodedesc}{LOAD_FAST}{var_num}
591 Pushes a reference to the local \code{co_varnames[\var{var_num}]} onto
592 the stack.
593 \end{opcodedesc}
595 \begin{opcodedesc}{STORE_FAST}{var_num}
596 Stores TOS into the local \code{co_varnames[\var{var_num}]}.
597 \end{opcodedesc}
599 \begin{opcodedesc}{DELETE_FAST}{var_num}
600 Deletes local \code{co_varnames[\var{var_num}]}.
601 \end{opcodedesc}
603 \begin{opcodedesc}{LOAD_CLOSURE}{i}
604 Pushes a reference to the cell contained in slot \var{i} of the
605 cell and free variable storage. The name of the variable is
606 \code{co_cellvars[\var{i}]} if \var{i} is less than the length of
607 \var{co_cellvars}. Otherwise it is
608 \code{co_freevars[\var{i} - len(co_cellvars)]}.
609 \end{opcodedesc}
611 \begin{opcodedesc}{LOAD_DEREF}{i}
612 Loads the cell contained in slot \var{i} of the cell and free variable
613 storage. Pushes a reference to the object the cell contains on the
614 stack.
615 \end{opcodedesc}
617 \begin{opcodedesc}{STORE_DEREF}{i}
618 Stores TOS into the cell contained in slot \var{i} of the cell and
619 free variable storage.
620 \end{opcodedesc}
622 \begin{opcodedesc}{SET_LINENO}{lineno}
623 Sets the current line number to \var{lineno}.
624 \end{opcodedesc}
626 \begin{opcodedesc}{RAISE_VARARGS}{argc}
627 Raises an exception. \var{argc} indicates the number of parameters
628 to the raise statement, ranging from 0 to 3. The handler will find
629 the traceback as TOS2, the parameter as TOS1, and the exception
630 as TOS.
631 \end{opcodedesc}
633 \begin{opcodedesc}{CALL_FUNCTION}{argc}
634 Calls a function. The low byte of \var{argc} indicates the number of
635 positional parameters, the high byte the number of keyword parameters.
636 On the stack, the opcode finds the keyword parameters first. For each
637 keyword argument, the value is on top of the key. Below the keyword
638 parameters, the positional parameters are on the stack, with the
639 right-most parameter on top. Below the parameters, the function object
640 to call is on the stack.
641 \end{opcodedesc}
643 \begin{opcodedesc}{MAKE_FUNCTION}{argc}
644 Pushes a new function object on the stack. TOS is the code associated
645 with the function. The function object is defined to have \var{argc}
646 default parameters, which are found below TOS.
647 \end{opcodedesc}
649 \begin{opcodedesc}{MAKE_CLOSURE}{argc}
650 Creates a new function object, sets its \var{func_closure} slot, and
651 pushes it on the stack. TOS is the code associated with the function.
652 If the code object has N free variables, the next N items on the stack
653 are the cells for these variables. The function also has \var{argc}
654 default parameters, where are found before the cells.
655 \end{opcodedesc}
657 \begin{opcodedesc}{BUILD_SLICE}{argc}
658 Pushes a slice object on the stack. \var{argc} must be 2 or 3. If it
659 is 2, \code{slice(TOS1, TOS)} is pushed; if it is 3,
660 \code{slice(TOS2, TOS1, TOS)} is pushed.
661 See the \code{slice()}\bifuncindex{slice} built-in function for more
662 information.
663 \end{opcodedesc}
665 \begin{opcodedesc}{EXTENDED_ARG}{ext}
666 Prefixes any opcode which has an argument too big to fit into the
667 default two bytes. \var{ext} holds two additional bytes which, taken
668 together with the subsequent opcode's argument, comprise a four-byte
669 argument, \var{ext} being the two most-significant bytes.
670 \end{opcodedesc}
672 \begin{opcodedesc}{CALL_FUNCTION_VAR}{argc}
673 Calls a function. \var{argc} is interpreted as in \code{CALL_FUNCTION}.
674 The top element on the stack contains the variable argument list, followed
675 by keyword and positional arguments.
676 \end{opcodedesc}
678 \begin{opcodedesc}{CALL_FUNCTION_KW}{argc}
679 Calls a function. \var{argc} is interpreted as in \code{CALL_FUNCTION}.
680 The top element on the stack contains the keyword arguments dictionary,
681 followed by explicit keyword and positional arguments.
682 \end{opcodedesc}
684 \begin{opcodedesc}{CALL_FUNCTION_VAR_KW}{argc}
685 Calls a function. \var{argc} is interpreted as in
686 \code{CALL_FUNCTION}. The top element on the stack contains the
687 keyword arguments dictionary, followed by the variable-arguments
688 tuple, followed by explicit keyword and positional arguments.
689 \end{opcodedesc}