On this page
dis.findlinestarts
Prev: dis.findlabels | Up: dis | Next: dis.get_instructions
Rel: dis.Bytecode, dis.code_info, dis.dis, dis.disassemble
Ref: docs.python.org — dis.findlinestarts
Tags: #public #python3 #stdlib #dis
Import
import dis
from dis import findlinestarts
Signature & Overview
dis.findlinestarts(code)
Find the offsets in a byte code which are start of lines in the source.
Usage
import dis
def fn(x):
y = x + 1
return y
starts = list(dis.findlinestarts(fn.__code__))
assert len(starts) >= 2
Gotchas
- Yields
(offset, lineno)pairs mapping bytecode offsets back to source lines.
REPL Inspect
from dis import findlinestarts
help(findlinestarts)
Linked from
Related notes
- tuts/python3/stdlib_module/dis/findlabels Linked here; links to this page; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/get_instructions Linked here; links to this page; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/Bytecode Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/code_info Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/dis Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/disassemble Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/dis/disco shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/distb shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/Instruction shared tags: #dis, #stdlib