| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Oops, looks like the APIs I based the PR on are not exported past 3.13+, will need to figure out a solution. The str.lower() and str.upper() primitives continue to claim victims even after a year |
Sorry, something went wrong.
|
|
||
| // The _PyUnicode_CheckConsistency definition has been moved to the internal API | ||
| // https://github.com/python/cpython/pull/106398 | ||
| #if defined(Py_DEBUG) && defined(CPY_3_13_FEATURES) |
There was a problem hiding this comment.
That was a mistake afaict, CPY_3_13_FEATURES is defined by us so that'd always evaluate to true
Sorry, something went wrong.
|
I was testing this branch on Python 3.11; For 3.13+ I had to fallback to CPython's generic dispatch for Unicode strings. This introduces the following regression for the latter versions (tested on 3.14)
|
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for the PR! Can you also compare performance against mypyc master, on Python 3.14?
Sorry, something went wrong.
|
Since lower and upper calls are very common, we might eventually want to include lower case / upper case tables for at least UCS-2 within librt (that are only included in the build if the primitives are actually used, i.e. as optional files). But the ascii case is very common, so this is already helpful. |
Sorry, something went wrong.
|
I applied the inlining and reran the benchmarks:
|
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks, looks good! I'm glad that we finally have primitives for these common operations.
Sorry, something went wrong.
#21553) 6th PR of #21418. This PR introduces two `i32 -> i32` case-conversion helpers, alongside the existing classifiers. **The constraint to flag**: A single i32 holds one codepoint, but some Unicode case mappings expand to multiple e.g `'ß'.upper()` becomes `'SS'`, `'fi'.upper()` becomes `'FI'` etc. For those inputs the primitive _returns the input unchanged_; This is the same split CPython makes between `Py_UNICODE_TOUPPER` (codepoint) and `str.upper()` (string), with the former returning the **first codepoint** of the expansion. Users needing full Unicode case conversion should call `s.upper()` / `s.lower()` on the string, for which we already have mypyc primitives (#20948). For ASCII benchmarks, the codepoint primitives are ~5x faster than their `str` counterparts, avoiding the 1-char allocation.
| Back | FazBrowse Home | New Git URL |
Fixes mypyc/mypyc#1088
Follow up on #19375 with full Unicode support:
Benchmarks (x10 M calls each)