[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

Mark Shannon report at bugs.python.org
Sun Apr 29 14:28:42 EDT 2018


New submission from Mark Shannon <mark at hotpy.org>:

The six complex bytecodes currently used for implementing 'with' and 'try' statements can be replaced with just two simpler bytecodes.
The six bytecodes are WITH_CLEANUP_START, WITH_CLEANUP_FINISH,
BEGIN_FINALLY, END_FINALLY, CALL_FINALLY and POP_FINALLY.
They can be replaced with RERAISE and WITH_EXCEPT_FINISH.

See https://bugs.python.org/issue32949 for more details of the new bytecodes and how they are used in the 'with' statement.

The try-finally statement can be implemented broadly as 
   SETUP_FINALLY except
   try-body
   POP_BLOCK
   finally-body
   JUMP exit
except:
   finally-body
exit:

----------
components: Interpreter Core
messages: 315905
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Simplify bytecodes for try-finally, try-except and with blocks.
versions: Python 3.8

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


More information about the Python-bugs-list mailing list