[Python-ideas] Augment dis.dis to autocompile strings

Nick Coghlan ncoghlan at gmail.com
Thu Jul 16 23:23:26 CEST 2009


Terry Reedy wrote:
> 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?

Not that I can see. +1.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------



More information about the Python-ideas mailing list