Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-124502: Optimize unicode_eq()#125105
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
* Cleanup unicode_compare_eq() code.* Copy unicode_compare_eq() code in unicode_eq(): the two functions are now identical.
Microbenchmark: importpyperfimport_testcapistr1="a"*10str2=str1.encode().decode()ifstr2isstr1:raiseExceptionrunner=pyperf.Runner()runner.bench_time_func('_PyUnicode_EQ',_testcapi.bench_eq,str1,str2)runner.bench_time_func('_PyUnicode_Equal',_testcapi.bench__equal,str1,str2) Result on Python built with PGO+LTO (without CPU isolation): The performance is the same. |
Uh oh!
There was an error while loading.Please reload this page.
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.
Why changeunicode_compare_eq()?
For comparison, results on the main branch, also with PGO+LTO: |
I like to reduce the scope of variables by only declaring them where they are first assigned. |
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.
If this PR is only aboutunique_eq(), change only it. Otherwise simply useunique_eq() instead ofunique_compare_eq(). There are no reasons to have two identical static functions with different names.
Once this PR will be merged, I plan to write a following PR to remove unicode_compare_eq() and _PyUnicode_EQ(). I limited this PR to optimizing unicode_eq() to be able to measure the speedup. Otherwise, it was too difficult to measure it. |
If you plan to remove s/unicode_compare_eq/unicode_eq/ |
As you wish: I reverted unicode_compare_eq() changes. |
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.
LGTM. Although I think that#125070 was clearer, because it shown the larger picture.
c203955 intopython:mainUh oh!
There was an error while loading.Please reload this page.
Merged, thanks for reviews. Follow-up PR:#125114 removes _PyUnicode_EQ(). |
Uh oh!
There was an error while loading.Please reload this page.