Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / bytecodes.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="module-dis.html" />
13<link rel="parent" href="module-dis.html" />
14<link rel="next" href="module-pickletools.html" />
15<meta name='aesop' content='information' />
16<title>18.10.1 Python Byte Code Instructions</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="18.10 dis "
24 href="module-dis.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="18.10 dis "
27 href="module-dis.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="18.11 pickletools "
30 href="module-pickletools.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="module-dis.html">18.10 dis </A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="module-dis.html">18.10 dis </A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="module-pickletools.html">18.11 pickletools </A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H2><A NAME="SECTION00201010000000000000000"></A>
55<A NAME="bytecodes"></A>
56<BR>
5718.10.1 Python Byte Code Instructions
58</H2>
59
60<P>
61The Python compiler currently generates the following byte code
62instructions.
63
64<P>
65
66<P>
67<dl><dt><b><tt class="opcode">STOP_CODE</tt></b></dt>
68<dd>
69Indicates end-of-code to the compiler, not used by the interpreter.
70</dt></dl>
71
72<P>
73<dl><dt><b><tt class="opcode">NOP</tt></b></dt>
74<dd>
75Do nothing code. Used as a placeholder by the bytecode optimizer.
76</dt></dl>
77
78<P>
79<dl><dt><b><tt class="opcode">POP_TOP</tt></b></dt>
80<dd>
81Removes the top-of-stack (TOS) item.
82</dt></dl>
83
84<P>
85<dl><dt><b><tt class="opcode">ROT_TWO</tt></b></dt>
86<dd>
87Swaps the two top-most stack items.
88</dt></dl>
89
90<P>
91<dl><dt><b><tt class="opcode">ROT_THREE</tt></b></dt>
92<dd>
93Lifts second and third stack item one position up, moves top down
94to position three.
95</dt></dl>
96
97<P>
98<dl><dt><b><tt class="opcode">ROT_FOUR</tt></b></dt>
99<dd>
100Lifts second, third and forth stack item one position up, moves top down to
101position four.
102</dt></dl>
103
104<P>
105<dl><dt><b><tt class="opcode">DUP_TOP</tt></b></dt>
106<dd>
107Duplicates the reference on top of the stack.
108</dt></dl>
109
110<P>
111Unary Operations take the top of the stack, apply the operation, and
112push the result back on the stack.
113
114<P>
115<dl><dt><b><tt class="opcode">UNARY_POSITIVE</tt></b></dt>
116<dd>
117Implements <code>TOS = +TOS</code>.
118</dt></dl>
119
120<P>
121<dl><dt><b><tt class="opcode">UNARY_NEGATIVE</tt></b></dt>
122<dd>
123Implements <code>TOS = -TOS</code>.
124</dt></dl>
125
126<P>
127<dl><dt><b><tt class="opcode">UNARY_NOT</tt></b></dt>
128<dd>
129Implements <code>TOS = not TOS</code>.
130</dt></dl>
131
132<P>
133<dl><dt><b><tt class="opcode">UNARY_CONVERT</tt></b></dt>
134<dd>
135Implements <code>TOS = `TOS`</code>.
136</dt></dl>
137
138<P>
139<dl><dt><b><tt class="opcode">UNARY_INVERT</tt></b></dt>
140<dd>
141Implements <code>TOS = ~TOS</code>.
142</dt></dl>
143
144<P>
145<dl><dt><b><tt class="opcode">GET_ITER</tt></b></dt>
146<dd>
147Implements <code>TOS = iter(TOS)</code>.
148</dt></dl>
149
150<P>
151Binary operations remove the top of the stack (TOS) and the second top-most
152stack item (TOS1) from the stack. They perform the operation, and put the
153result back on the stack.
154
155<P>
156<dl><dt><b><tt class="opcode">BINARY_POWER</tt></b></dt>
157<dd>
158Implements <code>TOS = TOS1 ** TOS</code>.
159</dt></dl>
160
161<P>
162<dl><dt><b><tt class="opcode">BINARY_MULTIPLY</tt></b></dt>
163<dd>
164Implements <code>TOS = TOS1 * TOS</code>.
165</dt></dl>
166
167<P>
168<dl><dt><b><tt class="opcode">BINARY_DIVIDE</tt></b></dt>
169<dd>
170Implements <code>TOS = TOS1 / TOS</code> when
171<code>from __future__ import division</code> is not in effect.
172</dt></dl>
173
174<P>
175<dl><dt><b><tt class="opcode">BINARY_FLOOR_DIVIDE</tt></b></dt>
176<dd>
177Implements <code>TOS = TOS1 // TOS</code>.
178</dt></dl>
179
180<P>
181<dl><dt><b><tt class="opcode">BINARY_TRUE_DIVIDE</tt></b></dt>
182<dd>
183Implements <code>TOS = TOS1 / TOS</code> when
184<code>from __future__ import division</code> is in effect.
185</dt></dl>
186
187<P>
188<dl><dt><b><tt class="opcode">BINARY_MODULO</tt></b></dt>
189<dd>
190Implements <code>TOS = TOS1 % TOS</code>.
191</dt></dl>
192
193<P>
194<dl><dt><b><tt class="opcode">BINARY_ADD</tt></b></dt>
195<dd>
196Implements <code>TOS = TOS1 + TOS</code>.
197</dt></dl>
198
199<P>
200<dl><dt><b><tt class="opcode">BINARY_SUBTRACT</tt></b></dt>
201<dd>
202Implements <code>TOS = TOS1 - TOS</code>.
203</dt></dl>
204
205<P>
206<dl><dt><b><tt class="opcode">BINARY_SUBSCR</tt></b></dt>
207<dd>
208Implements <code>TOS = TOS1[TOS]</code>.
209</dt></dl>
210
211<P>
212<dl><dt><b><tt class="opcode">BINARY_LSHIFT</tt></b></dt>
213<dd>
214Implements <code>TOS = TOS1 &lt;<code></code>&lt; TOS</code>.
215</dt></dl>
216
217<P>
218<dl><dt><b><tt class="opcode">BINARY_RSHIFT</tt></b></dt>
219<dd>
220Implements <code>TOS = TOS1 &gt;<code></code>&gt; TOS</code>.
221</dt></dl>
222
223<P>
224<dl><dt><b><tt class="opcode">BINARY_AND</tt></b></dt>
225<dd>
226Implements <code>TOS = TOS1 &amp; TOS</code>.
227</dt></dl>
228
229<P>
230<dl><dt><b><tt class="opcode">BINARY_XOR</tt></b></dt>
231<dd>
232Implements <code>TOS = TOS1 ^ TOS</code>.
233</dt></dl>
234
235<P>
236<dl><dt><b><tt class="opcode">BINARY_OR</tt></b></dt>
237<dd>
238Implements <code>TOS = TOS1 | TOS</code>.
239</dt></dl>
240
241<P>
242In-place operations are like binary operations, in that they remove TOS and
243TOS1, and push the result back on the stack, but the operation is done
244in-place when TOS1 supports it, and the resulting TOS may be (but does not
245have to be) the original TOS1.
246
247<P>
248<dl><dt><b><tt class="opcode">INPLACE_POWER</tt></b></dt>
249<dd>
250Implements in-place <code>TOS = TOS1 ** TOS</code>.
251</dt></dl>
252
253<P>
254<dl><dt><b><tt class="opcode">INPLACE_MULTIPLY</tt></b></dt>
255<dd>
256Implements in-place <code>TOS = TOS1 * TOS</code>.
257</dt></dl>
258
259<P>
260<dl><dt><b><tt class="opcode">INPLACE_DIVIDE</tt></b></dt>
261<dd>
262Implements in-place <code>TOS = TOS1 / TOS</code> when
263<code>from __future__ import division</code> is not in effect.
264</dt></dl>
265
266<P>
267<dl><dt><b><tt class="opcode">INPLACE_FLOOR_DIVIDE</tt></b></dt>
268<dd>
269Implements in-place <code>TOS = TOS1 // TOS</code>.
270</dt></dl>
271
272<P>
273<dl><dt><b><tt class="opcode">INPLACE_TRUE_DIVIDE</tt></b></dt>
274<dd>
275Implements in-place <code>TOS = TOS1 / TOS</code> when
276<code>from __future__ import division</code> is in effect.
277</dt></dl>
278
279<P>
280<dl><dt><b><tt class="opcode">INPLACE_MODULO</tt></b></dt>
281<dd>
282Implements in-place <code>TOS = TOS1 % TOS</code>.
283</dt></dl>
284
285<P>
286<dl><dt><b><tt class="opcode">INPLACE_ADD</tt></b></dt>
287<dd>
288Implements in-place <code>TOS = TOS1 + TOS</code>.
289</dt></dl>
290
291<P>
292<dl><dt><b><tt class="opcode">INPLACE_SUBTRACT</tt></b></dt>
293<dd>
294Implements in-place <code>TOS = TOS1 - TOS</code>.
295</dt></dl>
296
297<P>
298<dl><dt><b><tt class="opcode">INPLACE_LSHIFT</tt></b></dt>
299<dd>
300Implements in-place <code>TOS = TOS1 &lt;<code></code>&lt; TOS</code>.
301</dt></dl>
302
303<P>
304<dl><dt><b><tt class="opcode">INPLACE_RSHIFT</tt></b></dt>
305<dd>
306Implements in-place <code>TOS = TOS1 &gt;<code></code>&gt; TOS</code>.
307</dt></dl>
308
309<P>
310<dl><dt><b><tt class="opcode">INPLACE_AND</tt></b></dt>
311<dd>
312Implements in-place <code>TOS = TOS1 &amp; TOS</code>.
313</dt></dl>
314
315<P>
316<dl><dt><b><tt class="opcode">INPLACE_XOR</tt></b></dt>
317<dd>
318Implements in-place <code>TOS = TOS1 ^ TOS</code>.
319</dt></dl>
320
321<P>
322<dl><dt><b><tt class="opcode">INPLACE_OR</tt></b></dt>
323<dd>
324Implements in-place <code>TOS = TOS1 | TOS</code>.
325</dt></dl>
326
327<P>
328The slice opcodes take up to three parameters.
329
330<P>
331<dl><dt><b><tt class="opcode">SLICE+0</tt></b></dt>
332<dd>
333Implements <code>TOS = TOS[:]</code>.
334</dt></dl>
335
336<P>
337<dl><dt><b><tt class="opcode">SLICE+1</tt></b></dt>
338<dd>
339Implements <code>TOS = TOS1[TOS:]</code>.
340</dt></dl>
341
342<P>
343<dl><dt><b><tt class="opcode">SLICE+2</tt></b></dt>
344<dd>
345Implements <code>TOS = TOS1[:TOS]</code>.
346</dt></dl>
347
348<P>
349<dl><dt><b><tt class="opcode">SLICE+3</tt></b></dt>
350<dd>
351Implements <code>TOS = TOS2[TOS1:TOS]</code>.
352</dt></dl>
353
354<P>
355Slice assignment needs even an additional parameter. As any statement,
356they put nothing on the stack.
357
358<P>
359<dl><dt><b><tt class="opcode">STORE_SLICE+0</tt></b></dt>
360<dd>
361Implements <code>TOS[:] = TOS1</code>.
362</dt></dl>
363
364<P>
365<dl><dt><b><tt class="opcode">STORE_SLICE+1</tt></b></dt>
366<dd>
367Implements <code>TOS1[TOS:] = TOS2</code>.
368</dt></dl>
369
370<P>
371<dl><dt><b><tt class="opcode">STORE_SLICE+2</tt></b></dt>
372<dd>
373Implements <code>TOS1[:TOS] = TOS2</code>.
374</dt></dl>
375
376<P>
377<dl><dt><b><tt class="opcode">STORE_SLICE+3</tt></b></dt>
378<dd>
379Implements <code>TOS2[TOS1:TOS] = TOS3</code>.
380</dt></dl>
381
382<P>
383<dl><dt><b><tt class="opcode">DELETE_SLICE+0</tt></b></dt>
384<dd>
385Implements <code>del TOS[:]</code>.
386</dt></dl>
387
388<P>
389<dl><dt><b><tt class="opcode">DELETE_SLICE+1</tt></b></dt>
390<dd>
391Implements <code>del TOS1[TOS:]</code>.
392</dt></dl>
393
394<P>
395<dl><dt><b><tt class="opcode">DELETE_SLICE+2</tt></b></dt>
396<dd>
397Implements <code>del TOS1[:TOS]</code>.
398</dt></dl>
399
400<P>
401<dl><dt><b><tt class="opcode">DELETE_SLICE+3</tt></b></dt>
402<dd>
403Implements <code>del TOS2[TOS1:TOS]</code>.
404</dt></dl>
405
406<P>
407<dl><dt><b><tt class="opcode">STORE_SUBSCR</tt></b></dt>
408<dd>
409Implements <code>TOS1[TOS] = TOS2</code>.
410</dt></dl>
411
412<P>
413<dl><dt><b><tt class="opcode">DELETE_SUBSCR</tt></b></dt>
414<dd>
415Implements <code>del TOS1[TOS]</code>.
416</dt></dl>
417
418<P>
419Miscellaneous opcodes.
420
421<P>
422<dl><dt><b><tt class="opcode">PRINT_EXPR</tt></b></dt>
423<dd>
424Implements the expression statement for the interactive mode. TOS is
425removed from the stack and printed. In non-interactive mode, an
426expression statement is terminated with <code>POP_STACK</code>.
427</dt></dl>
428
429<P>
430<dl><dt><b><tt class="opcode">PRINT_ITEM</tt></b></dt>
431<dd>
432Prints TOS to the file-like object bound to <code>sys.stdout</code>. There
433is one such instruction for each item in the <tt class="keyword">print</tt> statement.
434</dt></dl>
435
436<P>
437<dl><dt><b><tt class="opcode">PRINT_ITEM_TO</tt></b></dt>
438<dd>
439Like <code>PRINT_ITEM</code>, but prints the item second from TOS to the
440file-like object at TOS. This is used by the extended print statement.
441</dt></dl>
442
443<P>
444<dl><dt><b><tt class="opcode">PRINT_NEWLINE</tt></b></dt>
445<dd>
446Prints a new line on <code>sys.stdout</code>. This is generated as the
447last operation of a <tt class="keyword">print</tt> statement, unless the statement
448ends with a comma.
449</dt></dl>
450
451<P>
452<dl><dt><b><tt class="opcode">PRINT_NEWLINE_TO</tt></b></dt>
453<dd>
454Like <code>PRINT_NEWLINE</code>, but prints the new line on the file-like
455object on the TOS. This is used by the extended print statement.
456</dt></dl>
457
458<P>
459<dl><dt><b><tt class="opcode">BREAK_LOOP</tt></b></dt>
460<dd>
461Terminates a loop due to a <tt class="keyword">break</tt> statement.
462</dt></dl>
463
464<P>
465<dl><dt><b><tt class="opcode">CONTINUE_LOOP</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>target</var></dt>
466<dd>
467Continues a loop due to a <tt class="keyword">continue</tt> statement. <var>target</var>
468is the address to jump to (which should be a <code>FOR_ITER</code>
469instruction).
470</dt></dl>
471
472<P>
473<dl><dt><b><tt class="opcode">LIST_APPEND</tt></b></dt>
474<dd>
475Calls <code>list.append(TOS1, TOS)</code>. Used to implement list comprehensions.
476</dt></dl>
477
478<P>
479<dl><dt><b><tt class="opcode">LOAD_LOCALS</tt></b></dt>
480<dd>
481Pushes a reference to the locals of the current scope on the stack.
482This is used in the code for a class definition: After the class body
483is evaluated, the locals are passed to the class definition.
484</dt></dl>
485
486<P>
487<dl><dt><b><tt class="opcode">RETURN_VALUE</tt></b></dt>
488<dd>
489Returns with TOS to the caller of the function.
490</dt></dl>
491
492<P>
493<dl><dt><b><tt class="opcode">YIELD_VALUE</tt></b></dt>
494<dd>
495Pops <code>TOS</code> and yields it from a generator.
496</dt></dl>
497
498<P>
499<dl><dt><b><tt class="opcode">IMPORT_STAR</tt></b></dt>
500<dd>
501Loads all symbols not starting with "<tt class="character">_</tt>" directly from the module TOS
502to the local namespace. The module is popped after loading all names.
503This opcode implements <code>from module import *</code>.
504</dt></dl>
505
506<P>
507<dl><dt><b><tt class="opcode">EXEC_STMT</tt></b></dt>
508<dd>
509Implements <code>exec TOS2,TOS1,TOS</code>. The compiler fills
510missing optional parameters with <code>None</code>.
511</dt></dl>
512
513<P>
514<dl><dt><b><tt class="opcode">POP_BLOCK</tt></b></dt>
515<dd>
516Removes one block from the block stack. Per frame, there is a
517stack of blocks, denoting nested loops, try statements, and such.
518</dt></dl>
519
520<P>
521<dl><dt><b><tt class="opcode">END_FINALLY</tt></b></dt>
522<dd>
523Terminates a <tt class="keyword">finally</tt> clause. The interpreter recalls
524whether the exception has to be re-raised, or whether the function
525returns, and continues with the outer-next block.
526</dt></dl>
527
528<P>
529<dl><dt><b><tt class="opcode">BUILD_CLASS</tt></b></dt>
530<dd>
531Creates a new class object. TOS is the methods dictionary, TOS1
532the tuple of the names of the base classes, and TOS2 the class name.
533</dt></dl>
534
535<P>
536All of the following opcodes expect arguments. An argument is two
537bytes, with the more significant byte last.
538
539<P>
540<dl><dt><b><tt class="opcode">STORE_NAME</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
541<dd>
542Implements <code>name = TOS</code>. <var>namei</var> is the index of <var>name</var>
543in the attribute <tt class="member">co_names</tt> of the code object.
544The compiler tries to use <code>STORE_LOCAL</code> or <code>STORE_GLOBAL</code>
545if possible.
546</dt></dl>
547
548<P>
549<dl><dt><b><tt class="opcode">DELETE_NAME</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
550<dd>
551Implements <code>del name</code>, where <var>namei</var> is the index into
552<tt class="member">co_names</tt> attribute of the code object.
553</dt></dl>
554
555<P>
556<dl><dt><b><tt class="opcode">UNPACK_SEQUENCE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>count</var></dt>
557<dd>
558Unpacks TOS into <var>count</var> individual values, which are put onto
559the stack right-to-left.
560</dt></dl>
561
562<P>
563<dl><dt><b><tt class="opcode">DUP_TOPX</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>count</var></dt>
564<dd>
565Duplicate <var>count</var> items, keeping them in the same order. Due to
566implementation limits, <var>count</var> should be between 1 and 5 inclusive.
567</dt></dl>
568
569<P>
570<dl><dt><b><tt class="opcode">STORE_ATTR</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
571<dd>
572Implements <code>TOS.name = TOS1</code>, where <var>namei</var> is the index
573of name in <tt class="member">co_names</tt>.
574</dt></dl>
575
576<P>
577<dl><dt><b><tt class="opcode">DELETE_ATTR</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
578<dd>
579Implements <code>del TOS.name</code>, using <var>namei</var> as index into
580<tt class="member">co_names</tt>.
581</dt></dl>
582
583<P>
584<dl><dt><b><tt class="opcode">STORE_GLOBAL</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
585<dd>
586Works as <code>STORE_NAME</code>, but stores the name as a global.
587</dt></dl>
588
589<P>
590<dl><dt><b><tt class="opcode">DELETE_GLOBAL</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
591<dd>
592Works as <code>DELETE_NAME</code>, but deletes a global name.
593</dt></dl>
594
595<P>
596<dl><dt><b><tt class="opcode">LOAD_CONST</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>consti</var></dt>
597<dd>
598Pushes "<tt class="samp">co_consts[<var>consti</var>]</tt>" onto the stack.
599</dt></dl>
600
601<P>
602<dl><dt><b><tt class="opcode">LOAD_NAME</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
603<dd>
604Pushes the value associated with "<tt class="samp">co_names[<var>namei</var>]</tt>" onto the stack.
605</dt></dl>
606
607<P>
608<dl><dt><b><tt class="opcode">BUILD_TUPLE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>count</var></dt>
609<dd>
610Creates a tuple consuming <var>count</var> items from the stack, and pushes
611the resulting tuple onto the stack.
612</dt></dl>
613
614<P>
615<dl><dt><b><tt class="opcode">BUILD_LIST</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>count</var></dt>
616<dd>
617Works as <code>BUILD_TUPLE</code>, but creates a list.
618</dt></dl>
619
620<P>
621<dl><dt><b><tt class="opcode">BUILD_MAP</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>zero</var></dt>
622<dd>
623Pushes a new empty dictionary object onto the stack. The argument is
624ignored and set to zero by the compiler.
625</dt></dl>
626
627<P>
628<dl><dt><b><tt class="opcode">LOAD_ATTR</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
629<dd>
630Replaces TOS with <code>getattr(TOS, co_names[<var>namei</var>])</code>.
631</dt></dl>
632
633<P>
634<dl><dt><b><tt class="opcode">COMPARE_OP</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>opname</var></dt>
635<dd>
636Performs a Boolean operation. The operation name can be found
637in <code>cmp_op[<var>opname</var>]</code>.
638</dt></dl>
639
640<P>
641<dl><dt><b><tt class="opcode">IMPORT_NAME</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
642<dd>
643Imports the module <code>co_names[<var>namei</var>]</code>. The module object is
644pushed onto the stack. The current namespace is not affected: for a
645proper import statement, a subsequent <code>STORE_FAST</code> instruction
646modifies the namespace.
647</dt></dl>
648
649<P>
650<dl><dt><b><tt class="opcode">IMPORT_FROM</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
651<dd>
652Loads the attribute <code>co_names[<var>namei</var>]</code> from the module found in
653TOS. The resulting object is pushed onto the stack, to be subsequently
654stored by a <code>STORE_FAST</code> instruction.
655</dt></dl>
656
657<P>
658<dl><dt><b><tt class="opcode">JUMP_FORWARD</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>delta</var></dt>
659<dd>
660Increments byte code counter by <var>delta</var>.
661</dt></dl>
662
663<P>
664<dl><dt><b><tt class="opcode">JUMP_IF_TRUE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>delta</var></dt>
665<dd>
666If TOS is true, increment the byte code counter by <var>delta</var>. TOS is
667left on the stack.
668</dt></dl>
669
670<P>
671<dl><dt><b><tt class="opcode">JUMP_IF_FALSE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>delta</var></dt>
672<dd>
673If TOS is false, increment the byte code counter by <var>delta</var>. TOS
674is not changed.
675</dt></dl>
676
677<P>
678<dl><dt><b><tt class="opcode">JUMP_ABSOLUTE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>target</var></dt>
679<dd>
680Set byte code counter to <var>target</var>.
681</dt></dl>
682
683<P>
684<dl><dt><b><tt class="opcode">FOR_ITER</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>delta</var></dt>
685<dd>
686<code>TOS</code> is an iterator. Call its <tt class="method">next()</tt> method. If this
687yields a new value, push it on the stack (leaving the iterator below
688it). If the iterator indicates it is exhausted <code>TOS</code> is
689popped, and the byte code counter is incremented by <var>delta</var>.
690</dt></dl>
691
692<P>
693<dl><dt><b><tt class="opcode">LOAD_GLOBAL</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>namei</var></dt>
694<dd>
695Loads the global named <code>co_names[<var>namei</var>]</code> onto the stack.
696</dt></dl>
697
698<P>
699<dl><dt><b><tt class="opcode">SETUP_LOOP</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>delta</var></dt>
700<dd>
701Pushes a block for a loop onto the block stack. The block spans
702from the current instruction with a size of <var>delta</var> bytes.
703</dt></dl>
704
705<P>
706<dl><dt><b><tt class="opcode">SETUP_EXCEPT</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>delta</var></dt>
707<dd>
708Pushes a try block from a try-except clause onto the block stack.
709<var>delta</var> points to the first except block.
710</dt></dl>
711
712<P>
713<dl><dt><b><tt class="opcode">SETUP_FINALLY</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>delta</var></dt>
714<dd>
715Pushes a try block from a try-except clause onto the block stack.
716<var>delta</var> points to the finally block.
717</dt></dl>
718
719<P>
720<dl><dt><b><tt class="opcode">LOAD_FAST</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>var_num</var></dt>
721<dd>
722Pushes a reference to the local <code>co_varnames[<var>var_num</var>]</code> onto
723the stack.
724</dt></dl>
725
726<P>
727<dl><dt><b><tt class="opcode">STORE_FAST</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>var_num</var></dt>
728<dd>
729Stores TOS into the local <code>co_varnames[<var>var_num</var>]</code>.
730</dt></dl>
731
732<P>
733<dl><dt><b><tt class="opcode">DELETE_FAST</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>var_num</var></dt>
734<dd>
735Deletes local <code>co_varnames[<var>var_num</var>]</code>.
736</dt></dl>
737
738<P>
739<dl><dt><b><tt class="opcode">LOAD_CLOSURE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>i</var></dt>
740<dd>
741Pushes a reference to the cell contained in slot <var>i</var> of the
742cell and free variable storage. The name of the variable is
743<code>co_cellvars[<var>i</var>]</code> if <var>i</var> is less than the length of
744<var>co_cellvars</var>. Otherwise it is
745<code>co_freevars[<var>i</var> - len(co_cellvars)]</code>.
746</dt></dl>
747
748<P>
749<dl><dt><b><tt class="opcode">LOAD_DEREF</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>i</var></dt>
750<dd>
751Loads the cell contained in slot <var>i</var> of the cell and free variable
752storage. Pushes a reference to the object the cell contains on the
753stack.
754</dt></dl>
755
756<P>
757<dl><dt><b><tt class="opcode">STORE_DEREF</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>i</var></dt>
758<dd>
759Stores TOS into the cell contained in slot <var>i</var> of the cell and
760free variable storage.
761</dt></dl>
762
763<P>
764<dl><dt><b><tt class="opcode">SET_LINENO</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>lineno</var></dt>
765<dd>
766This opcode is obsolete.
767</dt></dl>
768
769<P>
770<dl><dt><b><tt class="opcode">RAISE_VARARGS</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
771<dd>
772Raises an exception. <var>argc</var> indicates the number of parameters
773to the raise statement, ranging from 0 to 3. The handler will find
774the traceback as TOS2, the parameter as TOS1, and the exception
775as TOS.
776</dt></dl>
777
778<P>
779<dl><dt><b><tt class="opcode">CALL_FUNCTION</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
780<dd>
781Calls a function. The low byte of <var>argc</var> indicates the number of
782positional parameters, the high byte the number of keyword parameters.
783On the stack, the opcode finds the keyword parameters first. For each
784keyword argument, the value is on top of the key. Below the keyword
785parameters, the positional parameters are on the stack, with the
786right-most parameter on top. Below the parameters, the function object
787to call is on the stack.
788</dt></dl>
789
790<P>
791<dl><dt><b><tt class="opcode">MAKE_FUNCTION</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
792<dd>
793Pushes a new function object on the stack. TOS is the code associated
794with the function. The function object is defined to have <var>argc</var>
795default parameters, which are found below TOS.
796</dt></dl>
797
798<P>
799<dl><dt><b><tt class="opcode">MAKE_CLOSURE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
800<dd>
801Creates a new function object, sets its <var>func_closure</var> slot, and
802pushes it on the stack. TOS is the code associated with the function.
803If the code object has N free variables, the next N items on the stack
804are the cells for these variables. The function also has <var>argc</var>
805default parameters, where are found before the cells.
806</dt></dl>
807
808<P>
809<dl><dt><b><tt class="opcode">BUILD_SLICE</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
810<dd>
811Pushes a slice object on the stack. <var>argc</var> must be 2 or 3. If it
812is 2, <code>slice(TOS1, TOS)</code> is pushed; if it is 3,
813<code>slice(TOS2, TOS1, TOS)</code> is pushed.
814See the <code>slice()</code><a id='l2h-5014' xml:id='l2h-5014'></a> built-in function for more
815information.
816</dt></dl>
817
818<P>
819<dl><dt><b><tt class="opcode">EXTENDED_ARG</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>ext</var></dt>
820<dd>
821Prefixes any opcode which has an argument too big to fit into the
822default two bytes. <var>ext</var> holds two additional bytes which, taken
823together with the subsequent opcode's argument, comprise a four-byte
824argument, <var>ext</var> being the two most-significant bytes.
825</dt></dl>
826
827<P>
828<dl><dt><b><tt class="opcode">CALL_FUNCTION_VAR</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
829<dd>
830Calls a function. <var>argc</var> is interpreted as in <code>CALL_FUNCTION</code>.
831The top element on the stack contains the variable argument list, followed
832by keyword and positional arguments.
833</dt></dl>
834
835<P>
836<dl><dt><b><tt class="opcode">CALL_FUNCTION_KW</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
837<dd>
838Calls a function. <var>argc</var> is interpreted as in <code>CALL_FUNCTION</code>.
839The top element on the stack contains the keyword arguments dictionary,
840followed by explicit keyword and positional arguments.
841</dt></dl>
842
843<P>
844<dl><dt><b><tt class="opcode">CALL_FUNCTION_VAR_KW</tt></b>&nbsp;&nbsp;&nbsp;&nbsp;<var>argc</var></dt>
845<dd>
846Calls a function. <var>argc</var> is interpreted as in
847<code>CALL_FUNCTION</code>. The top element on the stack contains the
848keyword arguments dictionary, followed by the variable-arguments
849tuple, followed by explicit keyword and positional arguments.
850</dt></dl>
851
852<DIV CLASS="navigation">
853<div class='online-navigation'>
854<p></p><hr />
855<table align="center" width="100%" cellpadding="0" cellspacing="2">
856<tr>
857<td class='online-navigation'><a rel="prev" title="18.10 dis "
858 href="module-dis.html"><img src='../icons/previous.png'
859 border='0' height='32' alt='Previous Page' width='32' /></A></td>
860<td class='online-navigation'><a rel="parent" title="18.10 dis "
861 href="module-dis.html"><img src='../icons/up.png'
862 border='0' height='32' alt='Up One Level' width='32' /></A></td>
863<td class='online-navigation'><a rel="next" title="18.11 pickletools "
864 href="module-pickletools.html"><img src='../icons/next.png'
865 border='0' height='32' alt='Next Page' width='32' /></A></td>
866<td align="center" width="100%">Python Library Reference</td>
867<td class='online-navigation'><a rel="contents" title="Table of Contents"
868 href="contents.html"><img src='../icons/contents.png'
869 border='0' height='32' alt='Contents' width='32' /></A></td>
870<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
871 border='0' height='32' alt='Module Index' width='32' /></a></td>
872<td class='online-navigation'><a rel="index" title="Index"
873 href="genindex.html"><img src='../icons/index.png'
874 border='0' height='32' alt='Index' width='32' /></A></td>
875</tr></table>
876<div class='online-navigation'>
877<b class="navlabel">Previous:</b>
878<a class="sectref" rel="prev" href="module-dis.html">18.10 dis </A>
879<b class="navlabel">Up:</b>
880<a class="sectref" rel="parent" href="module-dis.html">18.10 dis </A>
881<b class="navlabel">Next:</b>
882<a class="sectref" rel="next" href="module-pickletools.html">18.11 pickletools </A>
883</div>
884</div>
885<hr />
886<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
887</DIV>
888<!--End of Navigation Panel-->
889<ADDRESS>
890See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
891</ADDRESS>
892</BODY>
893</HTML>