Message391509
The changes to pyc format aren't user visible so shouldn't matter,
but what about the dis output?
Consider this program:
def f():
try:
1/0
except:
return "fail"
Currently it compiles to:
2 0 SETUP_FINALLY 7 (to 16)
3 2 LOAD_CONST 1 (1)
4 LOAD_CONST 2 (0)
6 BINARY_TRUE_DIVIDE
8 POP_TOP
10 POP_BLOCK
12 LOAD_CONST 0 (None)
14 RETURN_VALUE
4 >> 16 POP_TOP
18 POP_TOP
20 POP_TOP
5 22 POP_EXCEPT
24 LOAD_CONST 3 ('fail')
26 RETURN_VALUE
With zero-cost exception handling, it will compile to something like:
2 0 NOP
3 2 LOAD_CONST 1 (1)
4 LOAD_CONST 2 (0)
6 BINARY_TRUE_DIVIDE
8 POP_TOP
10 LOAD_CONST 0 (None)
12 RETURN_VALUE
None 14 PUSH_EXCEPT
4 16 POP_TOP
18 POP_TOP
20 POP_TOP
5 22 POP_EXCEPT
24 LOAD_CONST 3 ('fail')
26 RETURN_VALUE
(There are additional optimizations that should be applied, but those are a separate issue)
The problem is that the exception handling flow is no longer visible.
Should we add it back in somehow, or just append the exception jump table? |
|
Date |
User |
Action |
Args |
2021-04-21 10:23:21 | Mark.Shannon | set | recipients:
+ Mark.Shannon, gvanrossum, rhettinger, chris.jerdonek, serhiy.storchaka, corona10, Yonatan Goldschmidt, hauntsaninja |
2021-04-21 10:23:21 | Mark.Shannon | set | messageid: <1619000601.04.0.0570466460459.issue40222@roundup.psfhosted.org> |
2021-04-21 10:23:21 | Mark.Shannon | link | issue40222 messages |
2021-04-21 10:23:20 | Mark.Shannon | create | |
|