Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3fdc97

Browse files
committed
SF bug 567826. Document new opcodes:
['BINARY_FLOOR_DIVIDE', 'BINARY_TRUE_DIVIDE', 'INPLACE_FLOOR_DIVIDE', 'INPLACE_TRUE_DIVIDE', 'GET_ITER', 'YIELD_VALUE', 'FOR_ITER', 'CONTINUE_LOOP']
1 parent 05e01ee commit e3fdc97

1 file changed

Lines changed: 50 additions & 6 deletions

File tree

Doc/lib/libdis.tex

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ \subsection{Python Byte Code Instructions}
166166
Implements \code{TOS = \~{}TOS}.
167167
\end{opcodedesc}
168168

169+
\begin{opcodedesc}{GET_ITER}{}
170+
Implements \code{TOS = iter(TOS)}.
171+
\end{opcodedesc}
172+
169173
Binary operations remove the top of the stack (TOS) and the second top-most
170174
stack item (TOS1) from the stack. They perform the operation, and put the
171175
result back on the stack.
@@ -179,7 +183,17 @@ \subsection{Python Byte Code Instructions}
179183
\end{opcodedesc}
180184

181185
\begin{opcodedesc}{BINARY_DIVIDE}{}
182-
Implements \code{TOS = TOS1 / TOS}.
186+
Implements \code{TOS = TOS1 / TOS} when
187+
\code{from __future__ import division} is not in effect.
188+
\end{opcodedesc}
189+
190+
\begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{}
191+
Implements \code{TOS = TOS1 // TOS}.
192+
\end{opcodedesc}
193+
194+
\begin{opcodedesc}{BINARY_TRUE_DIVIDE}{}
195+
Implements \code{TOS = TOS1 / TOS} when
196+
\code{from __future__ import division} is in effect.
183197
\end{opcodedesc}
184198

185199
\begin{opcodedesc}{BINARY_MODULO}{}
@@ -232,7 +246,17 @@ \subsection{Python Byte Code Instructions}
232246
\end{opcodedesc}
233247

234248
\begin{opcodedesc}{INPLACE_DIVIDE}{}
235-
Implements in-place \code{TOS = TOS1 / TOS}.
249+
Implements in-place \code{TOS = TOS1 / TOS} when
250+
\code{from __future__ import division} is not in effect.
251+
\end{opcodedesc}
252+
253+
\begin{opcodedesc}{INPLACE_FLOOR_DIVIDE}{}
254+
Implements in-place \code{TOS = TOS1 // TOS}.
255+
\end{opcodedesc}
256+
257+
\begin{opcodedesc}{INPLACE_TRUE_DIVIDE}{}
258+
Implements in-place \code{TOS = TOS1 / TOS} when
259+
\code{from __future__ import division} is in effect.
236260
\end{opcodedesc}
237261

238262
\begin{opcodedesc}{INPLACE_MODULO}{}
@@ -328,6 +352,8 @@ \subsection{Python Byte Code Instructions}
328352
Implements \code{del TOS1[TOS]}.
329353
\end{opcodedesc}
330354

355+
Miscellaneous opcodes.
356+
331357
\begin{opcodedesc}{PRINT_EXPR}{}
332358
Implements the expression statement for the interactive mode. TOS is
333359
removed from the stack and printed. In non-interactive mode, an
@@ -359,6 +385,12 @@ \subsection{Python Byte Code Instructions}
359385
Terminates a loop due to a \keyword{break} statement.
360386
\end{opcodedesc}
361387

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}
393+
362394
\begin{opcodedesc}{LOAD_LOCALS}{}
363395
Pushes a reference to the locals of the current scope on the stack.
364396
This is used in the code for a class definition: After the class body
@@ -369,6 +401,10 @@ \subsection{Python Byte Code Instructions}
369401
Returns with TOS to the caller of the function.
370402
\end{opcodedesc}
371403

404+
\begin{opcodedesc}{YIELD_VALUE}{}
405+
Pops \code{TOS} and yields it from a generator.
406+
\end{opcodedesc}
407+
372408
\begin{opcodedesc}{IMPORT_STAR}{}
373409
Loads all symbols not starting with \character{_} directly from the module TOS
374410
to the local namespace. The module is popped after loading all names.
@@ -513,11 +549,19 @@ \subsection{Python Byte Code Instructions}
513549
Set byte code counter to \var{target}.
514550
\end{opcodedesc}
515551

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}
558+
516559
\begin{opcodedesc}{FOR_LOOP}{delta}
517-
Iterate over a sequence. TOS is the current index, TOS1 the sequence.
518-
First, the next element is computed. If the sequence is exhausted,
519-
increment byte code counter by \var{delta}. Otherwise, push the
520-
sequence, the incremented counter, and the current item onto the stack.
560+
This opcode is obsolete.
561+
%Iterate over a sequence. TOS is the current index, TOS1 the sequence.
562+
%First, the next element is computed. If the sequence is exhausted,
563+
%increment byte code counter by \var{delta}. Otherwise, push the
564+
%sequence, the incremented counter, and the current item onto the stack.
521565
\end{opcodedesc}
522566

523567
%\begin{opcodedesc}{LOAD_LOCAL}{namei}

0 commit comments

Comments
 (0)