[Python-Dev] Disassembly of generated comprehensions

Neil Girdhar mistersheik at gmail.com
Sun Jan 25 12:55:52 CET 2015


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 (<code object <dictcomp> at
0x10160b7c0, file "<dis>", line 1>)
              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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150125/64d60caf/attachment.html>


More information about the Python-Dev mailing list