25 Jan
2015
25 Jan
'15
11:55 a.m.
How do I disassemble a generated comprehension? For example, I am trying to debug the following:
dis.dis('{**{} for x in [{1:2}]}') 1 0 LOAD_CONST 0 (
) 3 LOAD_CONST 1 ('<dictcomp>') 6 MAKE_FUNCTION 0 9 LOAD_CONST 2 (2) 12 LOAD_CONST 3 (1) 15 BUILD_MAP 1 18 BUILD_LIST 1 21 GET_ITER 22 CALL_FUNCTION 1 (1 positional, 0 keyword pair) 25 RETURN_VALUE
(This requires the new patch in issue 2292.) The code here looks fine to me, so I need to look into the code object <dictcomp>. How do I do that? Thanks, Neil