-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-119182: Optimize PyUnicode_FromFormat() #120796
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
Conversation
Use strchr() and ucs1lib_find_max_char() to optimize the code path formatting sub-strings between '%' formats.
Results of #120248 (comment) benchmark:
|
Objects/unicodeobject.c
Outdated
|
||
if (_PyUnicodeWriter_WriteASCIIString(writer, f, len) < 0) | ||
int is_ascii = (ucs1lib_find_max_char((Py_UCS1*)f, (Py_UCS1*)f + len) < 128); |
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.
You can run it once, for the whole format string.
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.
Right. I modified my PR to run it only once, good idea!
Merged, thanks for the reviews @serhiy-storchaka. |
Use strchr() and ucs1lib_find_max_char() to optimize the code path formatting sub-strings between '%' formats.
Use strchr() and ucs1lib_find_max_char() to optimize the code path formatting sub-strings between '%' formats.
Use strchr() and ucs1lib_find_max_char() to optimize the code path formatting sub-strings between '%' formats.
Use strchr() and ucs1lib_find_max_char() to optimize the code path formatting sub-strings between '%' formats.