Message 133464 - Python tracker

Message133464

Author ncoghlan
Recipients eltoder, ncoghlan, rhettinger
Date 2011-04-10.13:55:09
SpamBayes Score 1.175734e-06
Marked as misclassified No
Message-id <1302443709.83.0.92487481363.issue11816@psf.upfronthosting.co.za>
In-reply-to
Content
I really like the idea of adding some lower level infrastructure to dis to make it generator based, making the disassembly more amenable to programmatic manipulation.

Consider if, for each line disassemble() currently prints, we had an underlying iterator that yielded a named tuple consisting of (index, opcode, oparg, linestart, details). I've created a proof-of-concept for that in my sandbox (http://hg.python.org/sandbox/ncoghlan/file/get_opinfo/Lib/dis.py) which adds a get_opinfo() function that does exactly. With disassemble() rewritten to use that, test_dis and test_peepholer still pass as currently written.

Near-term, test_peepholer could easily continue to do what it does now (i.e. use the higher level dis() function and redirect sys.stdout). Longer term, it could be written to analyse the opcode stream instead of doing string comparisons.
History
Date User Action Args
2011-04-10 13:55:09ncoghlansetrecipients: + ncoghlan, rhettinger, eltoder
2011-04-10 13:55:09ncoghlansetmessageid: <1302443709.83.0.92487481363.issue11816@psf.upfronthosting.co.za>
2011-04-10 13:55:09ncoghlanlinkissue11816 messages
2011-04-10 13:55:09ncoghlancreate