]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#4222: document dis.findlabels() and dis.findlinestarts() and
authorGeorg Brandl <georg@python.org>
Thu, 1 Jan 2009 12:09:40 +0000 (12:09 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 1 Jan 2009 12:09:40 +0000 (12:09 +0000)
put them into dis.__all__.

Doc/library/dis.rst
Lib/dis.py

index e9cbb131ea9c3d4a48db206f9808100d6e1cfb9f..909e229ed10c861bc9236aa6092d720241a5de80 100644 (file)
@@ -64,10 +64,23 @@ The :mod:`dis` module defines the following functions and constants:
 
 .. function:: disco(code[, lasti])
 
-   A synonym for disassemble.  It is more convenient to type, and kept for
-   compatibility with earlier Python releases.
+   A synonym for :func:`disassemble`.  It is more convenient to type, and kept
+   for compatibility with earlier Python releases.
 
 
+.. function:: findlinestarts(code)
+
+   This generator function uses the ``co_firstlineno`` and ``co_lnotab``
+   attributes of the code object *code* to find the offsets which are starts of
+   lines in the source code.  They are generated as ``(offset, lineno)`` pairs.
+
+
+.. function:: findlabels(code)
+
+   Detect all offsets in the code object *code* which are jump targets, and
+   return a list of these offsets.
+   
+   
 .. data:: opname
 
    Sequence of operation names, indexable using the bytecode.
index 5a74b3ae894b7fb378973a772193c33ca298f1d2..e60e702036ca2c0677aa9fc729ce3214271ae55b 100644 (file)
@@ -6,7 +6,8 @@ import types
 from opcode import *
 from opcode import __all__ as _opcodes_all
 
-__all__ = ["dis","disassemble","distb","disco"] + _opcodes_all
+__all__ = ["dis", "disassemble", "distb", "disco",
+           "findlinestarts", "findlabels"] + _opcodes_all
 del _opcodes_all
 
 def dis(x=None):