⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bytecodes.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>17.10.1 Python Byte Code Instructions</title>
<META NAME="description" CONTENT="17.10.1 Python Byte Code Instructions">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="previous" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">
<LINK REL="up" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">
<LINK REL="next" href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">17.10 dis  </A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-dis.html" tppabs="http://www.python.org/doc/current/lib/module-dis.html">17.10 dis  </A>
<b class="navlabel">Next:</b> <a class="sectref" href="sgi.html" tppabs="http://www.python.org/doc/current/lib/sgi.html">18. SGI IRIX Specific</A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H2>
<BR>
17.10.1 Python Byte Code Instructions
</H2>

<P>
The Python compiler currently generates the following byte code
instructions.

<P>

<P>
<dl><dt><b><tt class='opcode'>STOP_CODE</tt></b>
<dd>
Indicates end-of-code to the compiler, not used by the interpreter.
</dl>

<P>
<dl><dt><b><tt class='opcode'>POP_TOP</tt></b>
<dd>
Removes the top-of-stack (TOS) item.
</dl>

<P>
<dl><dt><b><tt class='opcode'>ROT_TWO</tt></b>
<dd>
Swaps the two top-most stack items.
</dl>

<P>
<dl><dt><b><tt class='opcode'>ROT_THREE</tt></b>
<dd>
Lifts second and third stack item one position up, moves top down
to position three.
</dl>

<P>
<dl><dt><b><tt class='opcode'>ROT_FOUR</tt></b>
<dd>
Lifts second, third and forth stack item one position up, moves top down to
position four.
</dl>

<P>
<dl><dt><b><tt class='opcode'>DUP_TOP</tt></b>
<dd>
Duplicates the reference on top of the stack.
</dl>

<P>
Unary Operations take the top of the stack, apply the operation, and
push the result back on the stack.

<P>
<dl><dt><b><tt class='opcode'>UNARY_POSITIVE</tt></b>
<dd>
Implements <code>TOS = +TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>UNARY_NEGATIVE</tt></b>
<dd>
Implements <code>TOS = -TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>UNARY_NOT</tt></b>
<dd>
Implements <code>TOS = not TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>UNARY_CONVERT</tt></b>
<dd>
Implements <code>TOS = `TOS`</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>UNARY_INVERT</tt></b>
<dd>
Implements <code>TOS = ~TOS</code>.
</dl>

<P>
Binary operations remove the top of the stack (TOS) and the second top-most
stack item (TOS1) from the stack.  They perform the operation, and put the
result back on the stack.

<P>
<dl><dt><b><tt class='opcode'>BINARY_POWER</tt></b>
<dd>
Implements <code>TOS = TOS1 ** TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_MULTIPLY</tt></b>
<dd>
Implements <code>TOS = TOS1 * TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_DIVIDE</tt></b>
<dd>
Implements <code>TOS = TOS1 / TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_MODULO</tt></b>
<dd>
Implements <code>TOS = TOS1 % TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_ADD</tt></b>
<dd>
Implements <code>TOS = TOS1 + TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_SUBTRACT</tt></b>
<dd>
Implements <code>TOS = TOS1 - TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_SUBSCR</tt></b>
<dd>
Implements <code>TOS = TOS1[TOS]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_LSHIFT</tt></b>
<dd>
Implements <code>TOS = TOS1 &lt;&lt; TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_RSHIFT</tt></b>
<dd>
Implements <code>TOS = TOS1 &gt;&gt; TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_AND</tt></b>
<dd>
Implements <code>TOS = TOS1 &amp; TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_XOR</tt></b>
<dd>
Implements <code>TOS = TOS1 ^ TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>BINARY_OR</tt></b>
<dd>
Implements <code>TOS = TOS1 | TOS</code>.
</dl>

<P>
In-place operations are like binary operations, in that they remove TOS and
TOS1, and push the result back on the stack, but the operation is done
in-place when TOS1 supports it, and the resulting TOS may be (but does not
have to be) the original TOS1.

<P>
<dl><dt><b><tt class='opcode'>INPLACE_POWER</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 ** TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_MULTIPLY</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 * TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_DIVIDE</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 / TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_MODULO</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 % TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_ADD</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 + TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_SUBTRACT</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 - TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_LSHIFT</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 &lt;&lt; TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_RSHIFT</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 &gt;&gt; TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_AND</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 &amp; TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_XOR</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 ^ TOS</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>INPLACE_OR</tt></b>
<dd>
Implements in-place <code>TOS = TOS1 | TOS</code>.
</dl>

<P>
The slice opcodes take up to three parameters.

<P>
<dl><dt><b><tt class='opcode'>SLICE+0</tt></b>
<dd>
Implements <code>TOS = TOS[:]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>SLICE+1</tt></b>
<dd>
Implements <code>TOS = TOS1[TOS:]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>SLICE+2</tt></b>
<dd>
Implements <code>TOS = TOS1[:TOS1]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>SLICE+3</tt></b>
<dd>
Implements <code>TOS = TOS2[TOS1:TOS]</code>.
</dl>

<P>
Slice assignment needs even an additional parameter.  As any statement,
they put nothing on the stack.

<P>
<dl><dt><b><tt class='opcode'>STORE_SLICE+0</tt></b>
<dd>
Implements <code>TOS[:] = TOS1</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>STORE_SLICE+1</tt></b>
<dd>
Implements <code>TOS1[TOS:] = TOS2</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>STORE_SLICE+2</tt></b>
<dd>
Implements <code>TOS1[:TOS] = TOS2</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>STORE_SLICE+3</tt></b>
<dd>
Implements <code>TOS2[TOS1:TOS] = TOS3</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>DELETE_SLICE+0</tt></b>
<dd>
Implements <code>del TOS[:]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>DELETE_SLICE+1</tt></b>
<dd>
Implements <code>del TOS1[TOS:]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>DELETE_SLICE+2</tt></b>
<dd>
Implements <code>del TOS1[:TOS]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>DELETE_SLICE+3</tt></b>
<dd>
Implements <code>del TOS2[TOS1:TOS]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>STORE_SUBSCR</tt></b>
<dd>
Implements <code>TOS1[TOS] = TOS2</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>DELETE_SUBSCR</tt></b>
<dd>
Implements <code>del TOS1[TOS]</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>PRINT_EXPR</tt></b>
<dd>
Implements the expression statement for the interactive mode.  TOS is
removed from the stack and printed.  In non-interactive mode, an
expression statement is terminated with <code>POP_STACK</code>.
</dl>

<P>
<dl><dt><b><tt class='opcode'>PRINT_ITEM</tt></b>
<dd>
Prints TOS to the file-like object bound to <code>sys.stdout</code>.  There
is one such instruction for each item in the <tt class="keyword">print</tt> statement.
</dl>

<P>
<dl><dt><b><tt class='opcode'>PRINT_ITEM_TO</tt></b>
<dd>
Like <code>PRINT_ITEM</code>, but prints the item second from TOS to the
file-like object at TOS.  This is used by the extended print statement.
</dl>

<P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -