[New-bugs-announce] [issue17607] missed peephole optimization (unnecessary jump at end of function after yield)
Neal Norwitz
report at bugs.python.org
Mon Apr 1 06:45:51 CEST 2013
New submission from Neal Norwitz:
>>> def foo():
... if x:
... yield None
...
>>> dis.dis(foo)
2 0 LOAD_GLOBAL 0 (x)
3 POP_JUMP_IF_FALSE 14
3 6 LOAD_CONST 0 (None)
9 YIELD_VALUE
10 POP_TOP
11 JUMP_FORWARD 0 (to 14)
>> 14 LOAD_CONST 0 (None)
17 RETURN_VALUE
The JUMP_FORWARD at 11 is not necessary and is not in place with a return in the code:
>>> def foo():
... if x:
... return None
...
>>> dis.dis(foo)
2 0 LOAD_GLOBAL 0 (x)
3 POP_JUMP_IF_FALSE 10
3 6 LOAD_CONST 0 (None)
9 RETURN_VALUE
>> 10 LOAD_CONST 0 (None)
13 RETURN_VALUE
----------
components: Interpreter Core
messages: 185708
nosy: Neal.Norwitz
priority: normal
severity: normal
status: open
title: missed peephole optimization (unnecessary jump at end of function after yield)
type: performance
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17607>
_______________________________________
More information about the New-bugs-announce
mailing list