Title: Speed up parser by caching normalized identifiers? · Issue #148931 · python/cpython · GitHub
Open Graph Title: Speed up parser by caching normalized identifiers? · Issue #148931 · python/cpython
X Title: Speed up parser by caching normalized identifiers? · Issue #148931 · python/cpython
Description: Feature or enhancement Proposal: import ast body = '섀' + 'S' * 8000000 # non ASCII! ast.literal_eval('Y(' + body + ')' ) # pretty fast ast.literal_eval('Y(' + body + '=!') # noticably slower due to re-normalization After some profiling, ...
Open Graph Description: Feature or enhancement Proposal: import ast body = '섀' + 'S' * 8000000 # non ASCII! ast.literal_eval('Y(' + body + ')' ) # pretty fast ast.literal_eval('Y(' + body + '=!') # noticably slower due to...
X Description: Feature or enhancement Proposal: import ast body = '섀' + 'S' * 8000000 # non ASCII! ast.literal_eval('Y(' + body + ')' ) # pretty fast ast.literal_eval('Y(' ...
Opengraph URL: https://github.com/python/cpython/issues/148931
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Speed up parser by caching normalized identifiers?","articleBody":"# Feature or enhancement\n\n### Proposal:\n\n```python\nimport ast\nbody = '섀' + 'S' * 8000000 # non ASCII!\nast.literal_eval('Y(' + body + ')' ) # pretty fast\nast.literal_eval('Y(' + body + '=!') # noticably slower due to re-normalization\n```\n\nAfter some profiling, it is pretty clear that we are normalising the identifier *many* times:\n\n\u003cimg width=\"2552\" height=\"510\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/88ec6fc1-8220-460b-9783-655856cbfc95\" />\n\nInstead of normalising every time in `_PyPegen_new_identifier`:\n\nhttps://github.com/python/cpython/blob/448d7b96c181d13ca7f8977780e85b53b2716294/Parser/pegen.c#L502-L533\n\nMaybe we could cache it in the `Token` (I could write a patch with something like that :-)?\n\nCC @pablogsal @lysnikolaou \n\n\u003csub>This was found by OSS-Fuzz\u003c/sub>\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_","author":{"url":"https://github.com/StanFromIreland","@type":"Person","name":"StanFromIreland"},"datePublished":"2026-04-23T20:10:49Z","url":"https://github.com/python/cpython/issues/148931"}
| 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:a51ae18a-7938-b536-e6a1-092bef02affd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6EE:24645:1901554:20F1262:6B020F65 |
| html-safe-nonce | 479fffa2be385200ff4d816ba7ed6019f93e2ddaf8cb5f4de833115a92504c9f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkVFOjI0NjQ1OjE5MDE1NTQ6MjBGMTI2Mjo2QjAyMEY2NSIsInZpc2l0b3JfaWQiOiI1MTgyNDc2MjA4ODA5NTc4MzQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4893aab49a913df84f679d1adf01216366eb5e4bf19ea7729edef11846fd2c9e |
| hovercard-subject-tag | issue:4318588536 |
| 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/148931/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ba6c9703416d2640b489abcf9517b4aab46827521d1c6ceb14759c4f2ee50d4a/python/cpython/issues/148931 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ba6c9703416d2640b489abcf9517b4aab46827521d1c6ceb14759c4f2ee50d4a/python/cpython/issues/148931 |
| og:image:alt | Feature or enhancement Proposal: import ast body = '섀' + 'S' * 8000000 # non ASCII! ast.literal_eval('Y(' + body + ')' ) # pretty fast ast.literal_eval('Y(' + body + '=!') # noticably slower due to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | StanFromIreland |
| 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