[Python-ideas] Augment dis.dis to autocompile strings
Terry Reedy
tjreedy at udel.edu
Thu Jul 16 20:35:40 CEST 2009
Currently
"dis.dis(x=None)
Disassemble the x object. x can denote either a module, a class, a
method, a function, or a code object. "
The behavior depends on the class of x, so dis already has an internal
switch.
Currently, to see the assembly equivalent of CPython bytecode for a
small snippet, one must either wrap it in a function or *remember*
the exact idiom: compile("while True: break", "", "exec")
Proposal: if the input is a string, do the above (do what I mean)
instead of raising
TypeError: don't know how to disassemble str objects
Any negatives before I submit a feature request?
Terry Jan Reedy
More information about the Python-ideas
mailing list