[issue42696] Duplicated unused bytecodes at end of function

Mark Shannon report at bugs.python.org
Tue Dec 22 15:46:01 EST 2020


Mark Shannon <mark at hotpy.org> added the comment:

In what way is it "kludgy"?
There is a mathematical theorem that states that generated code will be imperfect, 
so we will have to live with that :)
https://en.wikipedia.org/wiki/Full_employment_theorem

3.10a produces more efficient bytecode than 3.9.

3.9:

  2           0 LOAD_GLOBAL              0 (range)
              2 LOAD_CONST               1 (10)
              4 CALL_FUNCTION            1
              6 GET_ITER
        >>    8 FOR_ITER                 8 (to 18)
             10 STORE_FAST               0 (i)

  3          12 POP_TOP
             14 JUMP_ABSOLUTE           18
             16 JUMP_ABSOLUTE            8

  4     >>   18 LOAD_CONST               2 (17)
             20 RETURN_VALUE

3.10a:

  2           0 LOAD_GLOBAL              0 (range)
              2 LOAD_CONST               1 (10)
              4 CALL_FUNCTION            1
              6 GET_ITER
              8 FOR_ITER                 8 (to 18)
             10 STORE_FAST               0 (i)

  3          12 POP_TOP

  4          14 LOAD_CONST               2 (17)
             16 RETURN_VALUE
        >>   18 LOAD_CONST               2 (17)
             20 RETURN_VALUE

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42696>
_______________________________________


More information about the Python-bugs-list mailing list