Title: bpo-33387: Simplify bytecodes for try-finally, try-except and with blocks. by markshannon · Pull Request #6641 · python/cpython · GitHub
Open Graph Title: bpo-33387: Simplify bytecodes for try-finally, try-except and with blocks. by markshannon · Pull Request #6641 · python/cpython
X Title: bpo-33387: Simplify bytecodes for try-finally, try-except and with blocks. by markshannon · Pull Request #6641 · python/cpython
Description: Quoting the bpo issue:
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_START.
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:
The implementation of with statements is a bit more complex. The with statement
with EXPR as VAR:
BLOCK
is implemented as:
SETUP_WITH ex
or POP_TOP
LOAD_CONST (None, None, None)
CALL_FUNCTION_EX 0
JUMP_FORWARD done
ex: WITH_EXCEPT_START (calls EXPR.__exit__)
POP_JUMP_IF_TRUE t:
RERAISE
t: POP_TOP * 3 (remove exception from stack)
POP_EXCEPT
POP_TOP
done:
https://bugs.python.org/issue33387
Open Graph Description: Quoting the bpo issue: The six complex bytecodes currently used for implementing 'with' and 'try' statements can be replaced with just two simpler bytecodes. The six bytecodes are ...
X Description: Quoting the bpo issue: The six complex bytecodes currently used for implementing 'with' and 'try' statements can be replaced with just two simpler bytecodes. The si...
Opengraph URL: https://github.com/python/cpython/pull/6641
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cba32410-3185-17b3-f770-8dc3715ee044 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8C0C:21D998:991D68:DEBADB:6A5741E8 |
| html-safe-nonce | ac7e2ec05f2a5c2e3317c126d1d10b4f0f87808dca119dabfa5af91f093ec5d5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzBDOjIxRDk5ODo5OTFENjg6REVCQURCOjZBNTc0MUU4IiwidmlzaXRvcl9pZCI6IjU1MTU2MzM3ODExMTIyNTkwNDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7b137635051f62cb9054d39fa70dcd0f976d2a19900b3e18302f3d11a7f3d97f |
| hovercard-subject-tag | pull_request:184847937 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/6641/files |
| twitter:image | https://avatars.githubusercontent.com/u/9448417?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/9448417?s=400&v=4 |
| og:image:alt | Quoting the bpo issue: The six complex bytecodes currently used for implementing 'with' and 'try' statements can be replaced with just two simpler bytecodes. The six bytecodes are ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2576d1f0198cf1588faf2edf27f1ed120903be10 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width