Title: gh-153668: Replace Unicode numeric switch with binary-search tables by scorpi023 · Pull Request #156081 · python/cpython · GitHub
Open Graph Title: gh-153668: Replace Unicode numeric switch with binary-search tables by scorpi023 · Pull Request #156081 · python/cpython
X Title: gh-153668: Replace Unicode numeric switch with binary-search tables by scorpi023 · Pull Request #156081 · python/cpython
Description: Fixes #153668. Summary makeunicodedata.py currently emits _PyUnicode_ToNumeric() as a switch with 2,023 case labels. On Windows ARM64, MSVC's /O2 optimizer consumes excessive memory and the x86-hosted ARM64 compiler fails with C1002 while compiling Objects/unicodectype.c. Generate a sorted code-point table, a parallel value-index table, and a table of the 151 UCD numeric-value entries instead. _PyUnicode_ToNumeric() now uses binary search and still returns -1.0 for code points without a numeric value. NUMERIC_MASK and _PyUnicode_IsNumeric() are unchanged. This is a source-level alternative to the temporary build workaround in #153669. That PR disables optimization for affected MSVC toolsets; this change keeps optimization enabled by removing the compiler-stressing generated switch. Windows ARM64 result VCTools 14.51.36231, Release /O2, on a Windows 11 ARM64 lab host: Compiler host main This PR HostX86 -> ARM64 C1002 after 11.487 s / 3.544 GB private success in 0.971 s / 0.037 GB HostARM64 -> ARM64 success in 29.482 s / 25.196 GB private success in 0.598 s / 0.050 GB Validation Full native ARM64 Release build: success. python -m test -j1 test_unicodedata test_str: 212 tests passed. python -m test -j1 -u cpu test_unicodedata: 73 tests passed. python -m test -j0 -x test_profiling: 49,207 tests passed across 442 test files. test_profiling was excluded because its sampling coordinator hangs independently on this lab image. Exhaustively compared all 1,114,112 Unicode code points with the previous generated switch; all 2,023 numeric mappings and non-numeric results match. Tools\patchcheck\patchcheck.py: passed. AI assistance: OpenAI Codex assisted with the investigation, implementation, and validation. This PR is opened as a draft so the submitter can complete the required human review before marking it ready. Issue: gh-153668
Open Graph Description: Fixes #153668. Summary makeunicodedata.py currently emits _PyUnicode_ToNumeric() as a switch with 2,023 case labels. On Windows ARM64, MSVC's /O2 optimizer consumes excessive memory and the x86...
X Description: Fixes #153668. Summary makeunicodedata.py currently emits _PyUnicode_ToNumeric() as a switch with 2,023 case labels. On Windows ARM64, MSVC's /O2 optimizer consumes excessive memory and the...
Opengraph URL: https://github.com/python/cpython/pull/156081
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b98755a2-daaa-07bd-3e95-dee2844c33e2 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C802:211F05:99F5B5:C247EC:6B023028 |
| html-safe-nonce | 5580cb4d4db6653dd843ef89cf062938c11e4baa4e0dc8106597aebee6d8bacc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODAyOjIxMUYwNTo5OUY1QjU6QzI0N0VDOjZCMDIzMDI4IiwidmlzaXRvcl9pZCI6IjU4MTY5MTM5OTQ0OTcyNzM4OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3cb8c7555a079113e656d06cf0f876f16e9f9d8ca2637c2ac258c5cc71522b53 |
| hovercard-subject-tag | pull_request:4319329374 |
| 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/156081/files |
| twitter:image | https://avatars.githubusercontent.com/u/27833957?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/27833957?s=400&v=4 |
| og:image:alt | Fixes #153668. Summary makeunicodedata.py currently emits _PyUnicode_ToNumeric() as a switch with 2,023 case labels. On Windows ARM64, MSVC's /O2 optimizer consumes excessive memory and the x86... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width