[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

Thomas Kluyver report at bugs.python.org
Tue Feb 12 18:50:01 CET 2013


Thomas Kluyver added the comment:

I've updated Nick's patch so that test_dis and test_peephole pass again, and added a prototype ByteCode class (without any docs or tests for now, to allow for API discussion).

The prototype ByteCode is instantiated with any of the objects that get_instructions already accepts (functions, methods, code strings & code objects). Iterating over it yields Instruction objects. It has info(), show_info() and display_code() methods, which correspond to the code_info(), show_code() and disassemble() functions.

I've tried to go for names that make sense, rather than names that fit the existing pattern, because the existing pattern feels a bit messy. E.g. the show_code() function doesn't actually show the code, so I've called its method equivalent show_info().

----------
nosy: +takluyver
Added file: http://bugs.python.org/file29051/dis_api.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11816>
_______________________________________


More information about the Python-bugs-list mailing list