-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[mypyc] Implement str.lower()
and str.upper()
primitive
#19375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[mypyc] Implement str.lower()
and str.upper()
primitive
#19375
Conversation
str.lower()
and str.upper()
primitive
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Left some comments -- the semantics are pretty tricky, and we need to be careful to catch all special cases. I'd suggest running a test (doesn't need to be included in this PR necessarily) comparing upper/lower of all length-1 strings with Python semantics.
assert "abc".lower() == "abc" | ||
assert "AbC123".lower() == "abc123" | ||
assert "áÉÍ".lower() == "áéí" | ||
assert "😴🚀".lower() == "😴🚀" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test special cases (verify that this agrees with normal Python semantics):
'SS'.lower() == 'ss'
'Σ'.lower()
'İ'.lower()
(changes length!)
assert "ABC".upper() == "ABC" | ||
assert "AbC123".upper() == "ABC123" | ||
assert "áéí".upper() == "ÁÉÍ" | ||
assert "😴🚀".upper() == "😴🚀" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test special case (verify that this agrees with normal Python semantics):
'ß'.upper() == 'SS'
'ffi'.upper()
(length increases!)
… logic for non-ASCII characters
…fallback logic and using direct table lookups
…static lookup tables and using direct character conversion
…ing for character conversion
…e special characters
Add primitive for
str.lower
andstr.upper
. Issue: mypyc/mypyc#1088