Message391509
| Author |
Mark.Shannon |
| Recipients |
Mark.Shannon, Yonatan Goldschmidt, chris.jerdonek, corona10, gvanrossum, hauntsaninja, rhettinger, serhiy.storchaka |
| Date |
2021年04月21日.10:23:20 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1619000601.04.0.0570466460459.issue40222@roundup.psfhosted.org> |
| In-reply-to |
| Content |
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? |
|