Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bf02cc84
Commit
bf02cc84
authored
Mar 02, 2015
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrap everything at 80 chars
parent
5f0d267c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
76 deletions
+78
-76
Doc/library/dis.rst
Doc/library/dis.rst
+78
-76
No files found.
Doc/library/dis.rst
View file @
bf02cc84
...
...
@@ -9,9 +9,9 @@
--------------
The :mod:`dis` module supports the analysis of CPython :term:`bytecode` by
disassembling it. The CPython bytecode which this module takes as an
input is defined in the file :file:`Include/opcode.h` and used by the compiler
and the
interpreter.
disassembling it. The CPython bytecode which this module takes as an
input is
defined in the file :file:`Include/opcode.h` and used by the compiler and the
interpreter.
.. impl-detail::
...
...
@@ -40,17 +40,18 @@ The :mod:`dis` module defines the following functions and constants:
.. function:: dis([bytesource])
Disassemble the *bytesource* object. *bytesource* can denote either a module,
a
class, a method, a function, or a code object. For a module, it disassembles
all functions. For a class, it disassembles all methods. For a single code
s
equence, it prints one line per bytecode instruction. If no object is
provided, it disassembles the last traceback.
Disassemble the *bytesource* object. *bytesource* can denote either a module,
a class, a method, a function, or a code object. For a module, it
disassembles all functions. For a class, it disassembles all methods. For a
s
ingle code sequence, it prints one line per bytecode instruction. If no
object is
provided, it disassembles the last traceback.
.. function:: distb([tb])
Disassembles the top-of-stack function of a traceback, using the last traceback
if none was passed. The instruction causing the exception is indicated.
Disassembles the top-of-stack function of a traceback, using the last
traceback if none was passed. The instruction causing the exception is
indicated.
.. function:: disassemble(code[, lasti])
...
...
@@ -233,8 +234,8 @@ result back on the stack.
.. opcode:: BINARY_DIVIDE ()
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
not
in effect.
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
not
in effect.
.. opcode:: BINARY_FLOOR_DIVIDE ()
...
...
@@ -244,8 +245,8 @@ result back on the stack.
.. opcode:: BINARY_TRUE_DIVIDE ()
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
in
effect.
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
in
effect.
.. opcode:: BINARY_MODULO ()
...
...
@@ -445,32 +446,32 @@ Miscellaneous opcodes.
.. opcode:: PRINT_EXPR ()
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 :opcode:`POP_TOP`.
from the stack and printed. In non-interactive mode, an expression statement
is
terminated with :opcode:`POP_TOP`.
.. opcode:: PRINT_ITEM ()
Prints TOS to the file-like object bound to ``sys.stdout``. There is one
such
instruction for each item in the :keyword:`print` statement.
Prints TOS to the file-like object bound to ``sys.stdout``. There is one
such
instruction for each item in the :keyword:`print` statement.
.. opcode:: PRINT_ITEM_TO ()
Like ``PRINT_ITEM``, but prints the item second from TOS to the file-like
object
at TOS. This is used by the extended print statement.
Like ``PRINT_ITEM``, but prints the item second from TOS to the file-like
object
at TOS. This is used by the extended print statement.
.. opcode:: PRINT_NEWLINE ()
Prints a new line on ``sys.stdout``. This is generated as the last operation
of
a :keyword:`print` statement, unless the statement ends with a comma.
Prints a new line on ``sys.stdout``. This is generated as the last operation
of
a :keyword:`print` statement, unless the statement ends with a comma.
.. opcode:: PRINT_NEWLINE_TO ()
Like ``PRINT_NEWLINE``, but prints the new line on the file-like object on
the
TOS. This is used by the extended print statement.
Like ``PRINT_NEWLINE``, but prints the new line on the file-like object on
the
TOS. This is used by the extended print statement.
.. opcode:: BREAK_LOOP ()
...
...
@@ -487,15 +488,15 @@ Miscellaneous opcodes.
.. opcode:: LIST_APPEND (i)
Calls ``list.append(TOS[-i], TOS)``. Used to implement list comprehensions.
While the appended value is popped off, the list object remains on the
s
tack s
o that it is available for further iterations of the loop.
While the appended value is popped off, the list object remains on the
stack
so that it is available for further iterations of the loop.
.. opcode:: LOAD_LOCALS ()
Pushes a reference to the locals of the current scope on the stack. This is
used
in the code for a class definition: After the class body is evaluated, the
locals are passed to the class definition.
Pushes a reference to the locals of the current scope on the stack. This is
used in the code for a class definition: After the class body is evaluated,
the
locals are passed to the class definition.
.. opcode:: RETURN_VALUE ()
...
...
@@ -510,9 +511,9 @@ Miscellaneous opcodes.
.. opcode:: IMPORT_STAR ()
Loads all symbols not starting with ``'_'`` directly from the module TOS to
the
local namespace. The module is popped after loading all names. This opcode
implements ``from module import *``.
Loads all symbols not starting with ``'_'`` directly from the module TOS to
the local namespace. The module is popped after loading all names. This
opcode
implements ``from module import *``.
.. opcode:: EXEC_STMT ()
...
...
@@ -523,8 +524,8 @@ Miscellaneous opcodes.
.. opcode:: POP_BLOCK ()
Removes one block from the block stack. Per frame, there is a
stack of blocks,
denoting nested loops, try statements, and such.
Removes one block from the block stack. Per frame, there is a
stack of
blocks,
denoting nested loops, try statements, and such.
.. opcode:: END_FINALLY ()
...
...
@@ -600,8 +601,8 @@ the more significant byte last.
.. opcode:: DUP_TOPX (count)
Duplicate *count* items, keeping them in the same order. Due to
implementation
limits, *count* should be between 1 and 5 inclusive.
Duplicate *count* items, keeping them in the same order. Due to
implementation
limits, *count* should be between 1 and 5 inclusive.
.. opcode:: STORE_ATTR (namei)
...
...
@@ -637,8 +638,8 @@ the more significant byte last.
.. opcode:: BUILD_TUPLE (count)
Creates a tuple consuming *count* items from the stack, and pushes the
resulting
tuple onto the stack.
Creates a tuple consuming *count* items from the stack, and pushes the
resulting
tuple onto the stack.
.. opcode:: BUILD_LIST (count)
...
...
@@ -667,9 +668,9 @@ the more significant byte last.
Imports the module ``co_names[namei]``. TOS and TOS1 are popped and provide
the *fromlist* and *level* arguments of :func:`__import__`. The module
object is pushed onto the stack. The current namespace is not affected:
for a proper import statement, a subsequent ``STORE_FAST`` instruction
modifies
the namespace.
object is pushed onto the stack. The current namespace is not affected:
for
a proper import statement, a subsequent ``STORE_FAST`` instruction modifies
the namespace.
.. opcode:: IMPORT_FROM (namei)
...
...
@@ -696,14 +697,14 @@ the more significant byte last.
.. opcode:: JUMP_IF_TRUE_OR_POP (target)
If TOS is true, sets the bytecode counter to *target* and leaves TOS
on the
stack. Otherwise (TOS is false), TOS is popped.
If TOS is true, sets the bytecode counter to *target* and leaves TOS
on the
stack. Otherwise (TOS is false), TOS is popped.
.. opcode:: JUMP_IF_FALSE_OR_POP (target)
If TOS is false, sets the bytecode counter to *target* and leaves
TOS on the
stack. Otherwise (TOS is true), TOS is popped.
If TOS is false, sets the bytecode counter to *target* and leaves
TOS on the
stack. Otherwise (TOS is true), TOS is popped.
.. opcode:: JUMP_ABSOLUTE (target)
...
...
@@ -732,19 +733,19 @@ the more significant byte last.
.. opcode:: SETUP_EXCEPT (delta)
Pushes a try block from a try-except clause onto the block stack. *delta*
points
to the first except block.
Pushes a try block from a try-except clause onto the block stack. *delta*
points
to the first except block.
.. opcode:: SETUP_FINALLY (delta)
Pushes a try block from a try-except clause onto the block stack. *delta*
points
to the finally block.
Pushes a try block from a try-except clause onto the block stack. *delta*
points
to the finally block.
.. opcode:: STORE_MAP ()
Store a key and value pair in a dictionary. Pops the key and value while
leaving
the dictionary on the stack.
Store a key and value pair in a dictionary. Pops the key and value while
leaving
the dictionary on the stack.
.. opcode:: LOAD_FAST (var_num)
...
...
@@ -797,18 +798,19 @@ the more significant byte last.
Calls a function. The low byte of *argc* indicates the number of positional
parameters, the high byte the number of keyword parameters. On the stack, the
opcode finds the keyword parameters first. For each keyword argument, the value
is on top of the key. Below the keyword parameters, the positional parameters
are on the stack, with the right-most parameter on top. Below the parameters,
the function object to call is on the stack. Pops all function arguments, and
the function itself off the stack, and pushes the return value.
opcode finds the keyword parameters first. For each keyword argument, the
value is on top of the key. Below the keyword parameters, the positional
parameters are on the stack, with the right-most parameter on top. Below the
parameters, the function object to call is on the stack. Pops all function
arguments, and the function itself off the stack, and pushes the return
value.
.. opcode:: MAKE_FUNCTION (argc)
Pushes a new function object on the stack. TOS is the code associated with
the
function. The function object is defined to have *argc* default parameters,
which are found below TOS.
Pushes a new function object on the stack. TOS is the code associated with
the function. The function object is defined to have *argc* default
parameters,
which are found below TOS.
.. opcode:: MAKE_CLOSURE (argc)
...
...
@@ -832,34 +834,34 @@ the more significant byte last.
Prefixes any opcode which has an argument too big to fit into the default two
bytes. *ext* holds two additional bytes which, taken together with the
subsequent opcode's argument, comprise a four-byte argument, *ext* being the
two
most-significant bytes.
subsequent opcode's argument, comprise a four-byte argument, *ext* being the
two
most-significant bytes.
.. opcode:: CALL_FUNCTION_VAR (argc)
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
top element
on the stack contains the variable argument list, followed by keyword and
positional arguments.
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
top element on the stack contains the variable argument list, followed by
keyword and
positional arguments.
.. opcode:: CALL_FUNCTION_KW (argc)
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
top element
on the stack contains the keyword arguments dictionary, followed by explicit
keyword and positional arguments.
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
top element on the stack contains the keyword arguments dictionary, followed
by explicit
keyword and positional arguments.
.. opcode:: CALL_FUNCTION_VAR_KW (argc)
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The top
element on the stack contains the keyword arguments dictionary, followed by the
variable-arguments tuple, followed by explicit keyword and positional arguments.
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
top element on the stack contains the keyword arguments dictionary, followed
by the variable-arguments tuple, followed by explicit keyword and positional
arguments.
.. opcode:: HAVE_ARGUMENT ()
This is not really an opcode. It identifies the dividing line between opcodes
which don't take arguments ``< HAVE_ARGUMENT`` and those which do ``>=
HAVE_ARGUMENT``.
This is not really an opcode. It identifies the dividing line between
opcodes which don't take arguments ``< HAVE_ARGUMENT`` and those which do
``>= HAVE_ARGUMENT``.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment