Title: Lower `BEFORE_WITH` and `BEFORE_ASYNC_WITH` to attribute lookups and calls. · Issue #120507 · python/cpython · GitHub
Open Graph Title: Lower `BEFORE_WITH` and `BEFORE_ASYNC_WITH` to attribute lookups and calls. · Issue #120507 · python/cpython
X Title: Lower `BEFORE_WITH` and `BEFORE_ASYNC_WITH` to attribute lookups and calls. · Issue #120507 · python/cpython
Description: With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1. BEFORE_WITH and BEFORE_ASYNC_WITH could be specialized, but they are bulky and won't optimize well in tier 2. I...
Open Graph Description: With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1. BEFORE_WITH and BEFORE_ASYNC_WITH could be specialized, but they are bu...
X Description: With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1. BEFORE_WITH and BEFORE_ASYNC_WITH could be specialized, but they are bu...
Opengraph URL: https://github.com/python/cpython/issues/120507
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lower `BEFORE_WITH` and `BEFORE_ASYNC_WITH` to attribute lookups and calls.","articleBody":"With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1.\r\n\r\n`BEFORE_WITH` and `BEFORE_ASYNC_WITH` could be specialized, but they are bulky and won't optimize well in tier 2.\r\nInstead, we should lower them to attribute lookups and calls which can then be optimized.\r\nWe should add a `LOAD_SPECIAL` instruction for loading dunder methods and replace `BEFORE_WITH` as follows:\r\n```\r\n COPY 1\r\n LOAD_SPECIAL __enter__ + NULL|self\r\n SWAP 3\r\n LOAD_SPECIAL __exit__\r\n SWAP 3\r\n CALL 0\r\n```\r\nLikewise for `BEFORE_ASYNC_WITH`.\r\n\r\nEven without any specialization of `LOAD_SPECIAL`, the `CALL` will be specialized and the JIT can eliminate the `COPY` and `SWAP`s.\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-120640\n* gh-120648\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/markshannon","@type":"Person","name":"markshannon"},"datePublished":"2024-06-14T14:28:06Z","url":"https://github.com/python/cpython/issues/120507"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ab7867c5-482c-4b89-1dcc-5fbddd7710bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8DE4:23E48:A4C12B:CE4D01:6B022F50 |
| html-safe-nonce | 70d225020e5a875982a067baaa78a7766fef4d006d18c988d9e3aae72acd4708 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REU0OjIzRTQ4OkE0QzEyQjpDRTREMDE6NkIwMjJGNTAiLCJ2aXNpdG9yX2lkIjoiODE1NzI0MTkxMDMxMDg3NDk2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 26a33d643826c24f1e6623ae66199d4a1232030872ec89fca328472f062c8637 |
| hovercard-subject-tag | issue:2353503584 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/120507/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bcf6477c3eda27b5b25f2ae467b849fcc34b479efb2c17d0a293789dc502ffe2/python/cpython/issues/120507 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bcf6477c3eda27b5b25f2ae467b849fcc34b479efb2c17d0a293789dc502ffe2/python/cpython/issues/120507 |
| og:image:alt | With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1. BEFORE_WITH and BEFORE_ASYNC_WITH could be specialized, but they are bu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | markshannon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width