On this page
dis.findlabels
Prev: dis.distb | Up: dis | Next: dis.findlinestarts
Rel: dis.Bytecode, dis.code_info, dis.dis, dis.disassemble
Ref: docs.python.org — dis.findlabels
Tags: #public #python3 #stdlib #dis
Import
import dis
from dis import findlabels
Signature & Overview
dis.findlabels(code)
Detect all offsets in a byte code which are jump targets.
Usage
import dis
def fn(x):
return 1 if x else 2
labels = dis.findlabels(fn.__code__.co_code)
assert isinstance(labels, list)
Gotchas
- Returns byte offsets that are jump targets in raw
co_code.
REPL Inspect
from dis import findlabels
help(findlabels)
Linked from
Related notes
- tuts/python3/stdlib_module/dis/distb Linked here; links to this page; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/findlinestarts 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/get_instructions shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/Instruction shared tags: #dis, #stdlib