Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/dis.rst

    r2 r391  
    1 
    21:mod:`dis` --- Disassembler for Python bytecode
    32===============================================
     
    65   :synopsis: Disassembler for Python bytecode.
    76
    8 
    9 The :mod:`dis` module supports the analysis of Python :term:`bytecode` by disassembling
    10 it.  Since there is no Python assembler, this module defines the Python assembly
    11 language.  The Python bytecode which this module takes as an input is defined
    12 in the file  :file:`Include/opcode.h` and used by the compiler and the
    13 interpreter.
     7**Source code:** :source:`Lib/dis.py`
     8
     9--------------
     10
     11The :mod:`dis` module supports the analysis of CPython :term:`bytecode` by
     12disassembling it. The CPython bytecode which this module takes as an
     13input is defined in the file :file:`Include/opcode.h` and used by the compiler
     14and the interpreter.
     15
     16.. impl-detail::
     17
     18   Bytecode is an implementation detail of the CPython interpreter!  No
     19   guarantees are made that bytecode will not be added, removed, or changed
     20   between versions of Python.  Use of this module should not be considered to
     21   work across Python VMs or Python releases.
    1422
    1523Example: Given the function :func:`myfunc`::
     
    6573.. function:: disco(code[, lasti])
    6674
    67    A synonym for disassemble.  It is more convenient to type, and kept for
    68    compatibility with earlier Python releases.
     75   A synonym for :func:`disassemble`.  It is more convenient to type, and kept
     76   for compatibility with earlier Python releases.
     77
     78
     79.. function:: findlinestarts(code)
     80
     81   This generator function uses the ``co_firstlineno`` and ``co_lnotab``
     82   attributes of the code object *code* to find the offsets which are starts of
     83   lines in the source code.  They are generated as ``(offset, lineno)`` pairs.
     84
     85
     86.. function:: findlabels(code)
     87
     88   Detect all offsets in the code object *code* which are jump targets, and
     89   return a list of these offsets.
    6990
    7091
     
    7697.. data:: opmap
    7798
    78    Dictionary mapping bytecodes to operation names.
     99   Dictionary mapping operation names to bytecodes.
    79100
    80101
     
    464485
    465486
    466 .. opcode:: LIST_APPEND ()
    467 
    468    Calls ``list.append(TOS1, TOS)``.  Used to implement list comprehensions.
     487.. opcode:: LIST_APPEND (i)
     488
     489   Calls ``list.append(TOS[-i], TOS)``.  Used to implement list comprehensions.
     490   While the appended value is popped off, the list object remains on the
     491   stack so that it is available for further iterations of the loop.
    469492
    470493
     
    516539   Creates a new class object.  TOS is the methods dictionary, TOS1 the tuple of
    517540   the names of the base classes, and TOS2 the class name.
     541
     542
     543.. opcode:: SETUP_WITH (delta)
     544
     545   This opcode performs several operations before a with block starts.  First,
     546   it loads :meth:`~object.__exit__` from the context manager and pushes it onto
     547   the stack for later use by :opcode:`WITH_CLEANUP`.  Then,
     548   :meth:`~object.__enter__` is called, and a finally block pointing to *delta*
     549   is pushed.  Finally, the result of calling the enter method is pushed onto
     550   the stack.  The next opcode will either ignore it (:opcode:`POP_TOP`), or
     551   store it in (a) variable(s) (:opcode:`STORE_FAST`, :opcode:`STORE_NAME`, or
     552   :opcode:`UNPACK_SEQUENCE`).
    518553
    519554
     
    650685
    651686
    652 .. opcode:: JUMP_IF_TRUE (delta)
    653 
    654    If TOS is true, increment the bytecode counter by *delta*.  TOS is left on the
    655    stack.
    656 
    657 
    658 .. opcode:: JUMP_IF_FALSE (delta)
    659 
    660    If TOS is false, increment the bytecode counter by *delta*.  TOS is not
    661    changed.
     687.. opcode:: POP_JUMP_IF_TRUE (target)
     688
     689   If TOS is true, sets the bytecode counter to *target*.  TOS is popped.
     690
     691
     692.. opcode:: POP_JUMP_IF_FALSE (target)
     693
     694   If TOS is false, sets the bytecode counter to *target*.  TOS is popped.
     695
     696
     697.. opcode:: JUMP_IF_TRUE_OR_POP (target)
     698
     699   If TOS is true, sets the bytecode counter to *target* and leaves TOS
     700   on the stack.  Otherwise (TOS is false), TOS is popped.
     701
     702
     703.. opcode:: JUMP_IF_FALSE_OR_POP (target)
     704
     705   If TOS is false, sets the bytecode counter to *target* and leaves
     706   TOS on the stack.  Otherwise (TOS is true), TOS is popped.
    662707
    663708
Note: See TracChangeset for help on using the changeset viewer.