[Python-checkins] r68119 - in python/trunk: Doc/library/dis.rst Lib/dis.py
georg.brandl
python-checkins at python.org
Thu Jan 1 13:09:40 CET 2009
Author: georg.brandl
Date: Thu Jan 1 13:09:40 2009
New Revision: 68119
Log:
#4222: document dis.findlabels() and dis.findlinestarts() and
put them into dis.__all__.
Modified:
python/trunk/Doc/library/dis.rst
python/trunk/Lib/dis.py
Modified: python/trunk/Doc/library/dis.rst
==============================================================================
--- python/trunk/Doc/library/dis.rst (original)
+++ python/trunk/Doc/library/dis.rst Thu Jan 1 13:09:40 2009
@@ -64,10 +64,23 @@
.. 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.
Modified: python/trunk/Lib/dis.py
==============================================================================
--- python/trunk/Lib/dis.py (original)
+++ python/trunk/Lib/dis.py Thu Jan 1 13:09:40 2009
@@ -6,7 +6,8 @@
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):
More information about the Python-checkins
mailing list