[mypyc] Add support for str.lower() and str.upper()#20948
[mypyc] Add support for str.lower() and str.upper()#20948VaggelisD wants to merge 4 commits intopython:masterfrom
str.lower() and str.upper()#20948Conversation
|
Oops, looks like the APIs I based the PR on are not exported past 3.13+, will need to figure out a solution. The |
|
|
||
| // The _PyUnicode_CheckConsistency definition has been moved to the internal API | ||
| // http://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
|
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)
|
JukkaL
left a comment
There was a problem hiding this comment.
Thanks for the PR! Can you also compare performance against mypyc master, on Python 3.14?
|
Since |
|
I applied the inlining and reran the benchmarks:
|
Fixes mypyc/mypyc#1088
Follow up on #19375 with full Unicode support:
CPyStr_ChangeCasehelper, parameterized by function pointers_PyUnicode_ToLowerFull/_PyUnicode_ToUpperFullfor Unicode which handle 1-to-N expansion (e.g.,ß→SS); This was a sticky point with the previous PR which relied onPy_UNICODE_TOLOWER/TOUPPER.len * 3UCS-4 buffer for the Unicode path; This is because each Unicode char may be expanded from 1 byte to 3Benchmarks (x10 M calls each)
""(empty)""(empty)