You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a0329ee
Browse filesBrowse the repository at this point in the historyBrowse files
[mypyc] Add primitives for str.islower, isupper and istitle (#22405)
Add primitives for `str.islower()`, `str.isupper()` and `str.istitle()`.
The implementations mirror CPython's and have a fast path for ASCII
strings (which have no titlecase characters). `str.islower()` and
`str.isupper()` share a helper.
Tests compare the results against CPython for every code point (alone
and combined with cased ASCII characters), and for a set of
multi-character strings including titlecase characters such as `Dž`.
The annotate test that used `str.islower()` as an example of a
non-native method call now uses `str.expandtabs()` instead.
Micro-benchmark (2M iterations over 11 short strings, compiled code,
generic method call through `Any` vs the new primitive, Python 3.13):
| Method | Before | After |
|---|---|---|
| `islower` | 0.362s | 0.129s |
| `isupper` | 0.337s | 0.104s |
| `istitle` | 0.375s | 0.159s |
Part of mypyc/mypyc#644.
0 commit comments