[New-bugs-announce] [issue28517] Dead code in wordcode
Serhiy Storchaka
report at bugs.python.org
Mon Oct 24 01:16:39 EDT 2016
New submission from Serhiy Storchaka:
>>> def func(test):
... if test == 1:
... return 1
... elif test == 2:
... return 2
... return 3
...
>>> import dis
>>> dis.dis(func)
Python 3.5:
2 0 LOAD_FAST 0 (test)
3 LOAD_CONST 1 (1)
6 COMPARE_OP 2 (==)
9 POP_JUMP_IF_FALSE 16
3 12 LOAD_CONST 1 (1)
15 RETURN_VALUE
4 >> 16 LOAD_FAST 0 (test)
19 LOAD_CONST 2 (2)
22 COMPARE_OP 2 (==)
25 POP_JUMP_IF_FALSE 32
5 28 LOAD_CONST 2 (2)
31 RETURN_VALUE
6 >> 32 LOAD_CONST 3 (3)
35 RETURN_VALUE
Python 3.6:
2 0 LOAD_FAST 0 (test)
2 LOAD_CONST 1 (1)
4 COMPARE_OP 2 (==)
6 POP_JUMP_IF_FALSE 14
3 8 LOAD_CONST 1 (1)
10 RETURN_VALUE
12 JUMP_FORWARD 12 (to 26)
4 >> 14 LOAD_FAST 0 (test)
16 LOAD_CONST 2 (2)
18 COMPARE_OP 2 (==)
20 POP_JUMP_IF_FALSE 26
5 22 LOAD_CONST 2 (2)
24 RETURN_VALUE
6 >> 26 LOAD_CONST 3 (3)
28 RETURN_VALUE
Note JUMP_FORWARD after RETURN_VALUE in 3.6 listing.
----------
components: Interpreter Core
messages: 279297
nosy: Demur Rumed, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Dead code in wordcode
type: behavior
versions: Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28517>
_______________________________________
More information about the New-bugs-announce
mailing list