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
Hide 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 @@
...
@@ -9,9 +9,9 @@
--------------
--------------
The :mod:`dis` module supports the analysis of CPython :term:`bytecode` by
The :mod:`dis` module supports the analysis of CPython :term:`bytecode` by
disassembling it. The CPython bytecode which this module takes as an
disassembling it. The CPython bytecode which this module takes as an
input is
input is defined in the file :file:`Include/opcode.h` and used by the compiler
defined in the file :file:`Include/opcode.h` and used by the compiler and the
and the
interpreter.
interpreter.
.. impl-detail::
.. impl-detail::
...
@@ -40,17 +40,18 @@ The :mod:`dis` module defines the following functions and constants:
...
@@ -40,17 +40,18 @@ The :mod:`dis` module defines the following functions and constants:
.. function:: dis([bytesource])
.. function:: dis([bytesource])
Disassemble the *bytesource* object. *bytesource* can denote either a module,
a
Disassemble the *bytesource* object. *bytesource* can denote either a module,
class, a method, a function, or a code object. For a module, it disassembles
a class, a method, a function, or a code object. For a module, it
all functions. For a class, it disassembles all methods. For a single code
disassembles all functions. For a class, it disassembles all methods. For a
s
equence, it prints one line per bytecode instruction. If no object is
s
ingle code sequence, it prints one line per bytecode instruction. If no
provided, it disassembles the last traceback.
object is
provided, it disassembles the last traceback.
.. function:: distb([tb])
.. function:: distb([tb])
Disassembles the top-of-stack function of a traceback, using the last traceback
Disassembles the top-of-stack function of a traceback, using the last
if none was passed. The instruction causing the exception is indicated.
traceback if none was passed. The instruction causing the exception is
indicated.
.. function:: disassemble(code[, lasti])
.. function:: disassemble(code[, lasti])
...
@@ -233,8 +234,8 @@ result back on the stack.
...
@@ -233,8 +234,8 @@ result back on the stack.
.. opcode:: BINARY_DIVIDE ()
.. opcode:: BINARY_DIVIDE ()
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
not
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
in effect.
not
in effect.
.. opcode:: BINARY_FLOOR_DIVIDE ()
.. opcode:: BINARY_FLOOR_DIVIDE ()
...
@@ -244,8 +245,8 @@ result back on the stack.
...
@@ -244,8 +245,8 @@ result back on the stack.
.. opcode:: BINARY_TRUE_DIVIDE ()
.. opcode:: BINARY_TRUE_DIVIDE ()
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
in
Implements ``TOS = TOS1 / TOS`` when ``from __future__ import division`` is
effect.
in
effect.
.. opcode:: BINARY_MODULO ()
.. opcode:: BINARY_MODULO ()
...
@@ -445,32 +446,32 @@ Miscellaneous opcodes.
...
@@ -445,32 +446,32 @@ Miscellaneous opcodes.
.. opcode:: PRINT_EXPR ()
.. opcode:: PRINT_EXPR ()
Implements the expression statement for the interactive mode. TOS is removed
Implements the expression statement for the interactive mode. TOS is removed
from the stack and printed. In non-interactive mode, an expression statement
is
from the stack and printed. In non-interactive mode, an expression statement
terminated with :opcode:`POP_TOP`.
is
terminated with :opcode:`POP_TOP`.
.. opcode:: PRINT_ITEM ()
.. opcode:: PRINT_ITEM ()
Prints TOS to the file-like object bound to ``sys.stdout``. There is one
such
Prints TOS to the file-like object bound to ``sys.stdout``. There is one
instruction for each item in the :keyword:`print` statement.
such
instruction for each item in the :keyword:`print` statement.
.. opcode:: PRINT_ITEM_TO ()
.. opcode:: PRINT_ITEM_TO ()
Like ``PRINT_ITEM``, but prints the item second from TOS to the file-like
object
Like ``PRINT_ITEM``, but prints the item second from TOS to the file-like
at TOS. This is used by the extended print statement.
object
at TOS. This is used by the extended print statement.
.. opcode:: PRINT_NEWLINE ()
.. opcode:: PRINT_NEWLINE ()
Prints a new line on ``sys.stdout``. This is generated as the last operation
of
Prints a new line on ``sys.stdout``. This is generated as the last operation
a :keyword:`print` statement, unless the statement ends with a comma.
of
a :keyword:`print` statement, unless the statement ends with a comma.
.. opcode:: PRINT_NEWLINE_TO ()
.. opcode:: PRINT_NEWLINE_TO ()
Like ``PRINT_NEWLINE``, but prints the new line on the file-like object on
the
Like ``PRINT_NEWLINE``, but prints the new line on the file-like object on
TOS. This is used by the extended print statement.
the
TOS. This is used by the extended print statement.
.. opcode:: BREAK_LOOP ()
.. opcode:: BREAK_LOOP ()
...
@@ -487,15 +488,15 @@ Miscellaneous opcodes.
...
@@ -487,15 +488,15 @@ Miscellaneous opcodes.
.. opcode:: LIST_APPEND (i)
.. opcode:: LIST_APPEND (i)
Calls ``list.append(TOS[-i], TOS)``. Used to implement list comprehensions.
Calls ``list.append(TOS[-i], TOS)``. Used to implement list comprehensions.
While the appended value is popped off, the list object remains on the
While the appended value is popped off, the list object remains on the
stack
s
tack s
o that it is available for further iterations of the loop.
so that it is available for further iterations of the loop.
.. opcode:: LOAD_LOCALS ()
.. opcode:: LOAD_LOCALS ()
Pushes a reference to the locals of the current scope on the stack. This is
used
Pushes a reference to the locals of the current scope on the stack. This is
in the code for a class definition: After the class body is evaluated, the
used in the code for a class definition: After the class body is evaluated,
locals are passed to the class definition.
the
locals are passed to the class definition.
.. opcode:: RETURN_VALUE ()
.. opcode:: RETURN_VALUE ()
...
@@ -510,9 +511,9 @@ Miscellaneous opcodes.
...
@@ -510,9 +511,9 @@ Miscellaneous opcodes.
.. opcode:: IMPORT_STAR ()
.. opcode:: IMPORT_STAR ()
Loads all symbols not starting with ``'_'`` directly from the module TOS to
the
Loads all symbols not starting with ``'_'`` directly from the module TOS to
local namespace. The module is popped after loading all names. This opcode
the local namespace. The module is popped after loading all names. This
implements ``from module import *``.
opcode
implements ``from module import *``.
.. opcode:: EXEC_STMT ()
.. opcode:: EXEC_STMT ()
...
@@ -523,8 +524,8 @@ Miscellaneous opcodes.
...
@@ -523,8 +524,8 @@ Miscellaneous opcodes.
.. opcode:: POP_BLOCK ()
.. opcode:: POP_BLOCK ()
Removes one block from the block stack. Per frame, there is a
stack of blocks,
Removes one block from the block stack. Per frame, there is a
stack of
denoting nested loops, try statements, and such.
blocks,
denoting nested loops, try statements, and such.
.. opcode:: END_FINALLY ()
.. opcode:: END_FINALLY ()
...
@@ -600,8 +601,8 @@ the more significant byte last.
...
@@ -600,8 +601,8 @@ the more significant byte last.
.. opcode:: DUP_TOPX (count)
.. opcode:: DUP_TOPX (count)
Duplicate *count* items, keeping them in the same order. Due to
implementation
Duplicate *count* items, keeping them in the same order. Due to
limits, *count* should be between 1 and 5 inclusive.
implementation
limits, *count* should be between 1 and 5 inclusive.
.. opcode:: STORE_ATTR (namei)
.. opcode:: STORE_ATTR (namei)
...
@@ -637,8 +638,8 @@ the more significant byte last.
...
@@ -637,8 +638,8 @@ the more significant byte last.
.. opcode:: BUILD_TUPLE (count)
.. opcode:: BUILD_TUPLE (count)
Creates a tuple consuming *count* items from the stack, and pushes the
resulting
Creates a tuple consuming *count* items from the stack, and pushes the
tuple onto the stack.
resulting
tuple onto the stack.
.. opcode:: BUILD_LIST (count)
.. opcode:: BUILD_LIST (count)
...
@@ -667,9 +668,9 @@ the more significant byte last.
...
@@ -667,9 +668,9 @@ the more significant byte last.
Imports the module ``co_names[namei]``. TOS and TOS1 are popped and provide
Imports the module ``co_names[namei]``. TOS and TOS1 are popped and provide
the *fromlist* and *level* arguments of :func:`__import__`. The module
the *fromlist* and *level* arguments of :func:`__import__`. The module
object is pushed onto the stack. The current namespace is not affected:
object is pushed onto the stack. The current namespace is not affected:
for
for a proper import statement, a subsequent ``STORE_FAST`` instruction
a proper import statement, a subsequent ``STORE_FAST`` instruction modifies
modifies
the namespace.
the namespace.
.. opcode:: IMPORT_FROM (namei)
.. opcode:: IMPORT_FROM (namei)
...
@@ -696,14 +697,14 @@ the more significant byte last.
...
@@ -696,14 +697,14 @@ the more significant byte last.
.. opcode:: JUMP_IF_TRUE_OR_POP (target)
.. opcode:: JUMP_IF_TRUE_OR_POP (target)
If TOS is true, sets the bytecode counter to *target* and leaves TOS
If TOS is true, sets the bytecode counter to *target* and leaves TOS
on the
on the
stack. Otherwise (TOS is false), TOS is popped.
stack. Otherwise (TOS is false), TOS is popped.
.. opcode:: JUMP_IF_FALSE_OR_POP (target)
.. opcode:: JUMP_IF_FALSE_OR_POP (target)
If TOS is false, sets the bytecode counter to *target* and leaves
If TOS is false, sets the bytecode counter to *target* and leaves
TOS on the
TOS on the
stack. Otherwise (TOS is true), TOS is popped.
stack. Otherwise (TOS is true), TOS is popped.
.. opcode:: JUMP_ABSOLUTE (target)
.. opcode:: JUMP_ABSOLUTE (target)
...
@@ -732,19 +733,19 @@ the more significant byte last.
...
@@ -732,19 +733,19 @@ the more significant byte last.
.. opcode:: SETUP_EXCEPT (delta)
.. opcode:: SETUP_EXCEPT (delta)
Pushes a try block from a try-except clause onto the block stack. *delta*
points
Pushes a try block from a try-except clause onto the block stack. *delta*
to the first except block.
points
to the first except block.
.. opcode:: SETUP_FINALLY (delta)
.. opcode:: SETUP_FINALLY (delta)
Pushes a try block from a try-except clause onto the block stack. *delta*
points
Pushes a try block from a try-except clause onto the block stack. *delta*
to the finally block.
points
to the finally block.
.. opcode:: STORE_MAP ()
.. opcode:: STORE_MAP ()
Store a key and value pair in a dictionary. Pops the key and value while
leaving
Store a key and value pair in a dictionary. Pops the key and value while
the dictionary on the stack.
leaving
the dictionary on the stack.
.. opcode:: LOAD_FAST (var_num)
.. opcode:: LOAD_FAST (var_num)
...
@@ -764,8 +765,8 @@ the more significant byte last.
...
@@ -764,8 +765,8 @@ the more significant byte last.
.. opcode:: LOAD_CLOSURE (i)
.. opcode:: LOAD_CLOSURE (i)
Pushes a reference to the cell contained in slot *i* of the cell and free
Pushes a reference to the cell contained in slot *i* of the cell and free
variable storage. The name of the variable is
``co_cellvars[i]`` if *i* is
variable storage. The name of the variable is ``co_cellvars[i]`` if *i* is
less than the length of *co_cellvars*. Otherwise it is
``co_freevars[i -
less than the length of *co_cellvars*. Otherwise it is ``co_freevars[i -
len(co_cellvars)]``.
len(co_cellvars)]``.
...
@@ -797,18 +798,19 @@ the more significant byte last.
...
@@ -797,18 +798,19 @@ the more significant byte last.
Calls a function. The low byte of *argc* indicates the number of positional
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
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
opcode finds the keyword parameters first. For each keyword argument, the
is on top of the key. Below the keyword parameters, the positional parameters
value is on top of the key. Below the keyword parameters, the positional
are on the stack, with the right-most parameter on top. Below the parameters,
parameters are on the stack, with the right-most parameter on top. Below the
the function object to call is on the stack. Pops all function arguments, and
parameters, the function object to call is on the stack. Pops all function
the function itself off the stack, and pushes the return value.
arguments, and the function itself off the stack, and pushes the return
value.
.. opcode:: MAKE_FUNCTION (argc)
.. opcode:: MAKE_FUNCTION (argc)
Pushes a new function object on the stack. TOS is the code associated with
the
Pushes a new function object on the stack. TOS is the code associated with
function. The function object is defined to have *argc* default parameters,
the function. The function object is defined to have *argc* default
which are found below TOS.
parameters,
which are found below TOS.
.. opcode:: MAKE_CLOSURE (argc)
.. opcode:: MAKE_CLOSURE (argc)
...
@@ -832,34 +834,34 @@ the more significant byte last.
...
@@ -832,34 +834,34 @@ the more significant byte last.
Prefixes any opcode which has an argument too big to fit into the default two
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
bytes. *ext* holds two additional bytes which, taken together with the
subsequent opcode's argument, comprise a four-byte argument, *ext* being the
two
subsequent opcode's argument, comprise a four-byte argument, *ext* being the
most-significant bytes.
two
most-significant bytes.
.. opcode:: CALL_FUNCTION_VAR (argc)
.. opcode:: CALL_FUNCTION_VAR (argc)
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
top element
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
on the stack contains the variable argument list, followed by keyword and
top element on the stack contains the variable argument list, followed by
positional arguments.
keyword and
positional arguments.
.. opcode:: CALL_FUNCTION_KW (argc)
.. opcode:: CALL_FUNCTION_KW (argc)
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
top element
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
on the stack contains the keyword arguments dictionary, followed by explicit
top element on the stack contains the keyword arguments dictionary, followed
keyword and positional arguments.
by explicit
keyword and positional arguments.
.. opcode:: CALL_FUNCTION_VAR_KW (argc)
.. opcode:: CALL_FUNCTION_VAR_KW (argc)
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The top
Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The
element on the stack contains the keyword arguments dictionary, followed by the
top element on the stack contains the keyword arguments dictionary, followed
variable-arguments tuple, followed by explicit keyword and positional arguments.
by the variable-arguments tuple, followed by explicit keyword and positional
arguments.
.. opcode:: HAVE_ARGUMENT ()
.. opcode:: HAVE_ARGUMENT ()
This is not really an opcode. It identifies the dividing line between opcodes
This is not really an opcode. It identifies the dividing line between
which don't take arguments ``< HAVE_ARGUMENT`` and those which do ``>=
opcodes which don't take arguments ``< HAVE_ARGUMENT`` and those which do
HAVE_ARGUMENT``.
``>= 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