[Tutor] bytecode primer, and avoiding a monster download

Dave Angel davea at davea.name
Tue May 28 13:18:39 CEST 2013


On 05/28/2013 07:02 AM, Jim Mooney wrote:
> On 27 May 2013 16:20, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
>>
>> To me, the bytecodes are the literal hex values corresponding
>> to the Python "assembler" statements. Are you sure you need the bytecodes?
>> You can use the standard library to generate the
>> assembler listing from the Python code.
>
> Ah good, how do I do that? What's the module? Thanks.
>

Alan and Devin already gave more specifics, but to repeat,

import dis

dis.dis(myfunction)

will disassemble one function.

That's not all that's in the byte-code file, but this is 98% of what you 
probably want out of it.  And you can do it in the debugger with just 
the standard library.


-- 
DaveA


More information about the Tutor mailing list