gh-149079: Optimize sorting in unicodedata.normalize() - #150782
Conversation
Sort the Py_UCS4 buffer instead of PyUnicodeObject. This allows to avoid the use of PyUnicode_READ() and PyUnicode_WRITE().
Baseline: 100 loops, best of 5: 3.76 msec per loop Baseline: 100 loops, best of 5: 3.99 msec per loop |
|
@serhiy-storchaka On your benchmark I can improve from 3.75 ms to 2.0 ms by using a more efficient search in |
Looks interesting. But this is a different issue, not directly related to #149079. Can you open a new issue? |
eendebakpt
left a comment
There was a problem hiding this comment.
I benchmarked the PR (rebased onto main first) and found a 10% to 20% speedup on the benchmarks.
|
Thank you! |
…H-150782) Sort the Py_UCS4 buffer instead of PyUnicodeObject. This allows to avoid the use of PyUnicode_READ() and PyUnicode_WRITE().
Sort the Py_UCS4 buffer instead of PyUnicodeObject. This allows to avoid the use of PyUnicode_READ() and PyUnicode_WRITE().
unicodedata.normalize("NFC")canonical ordering #149079