[issue39588] Use memcpy() instead of for() loops in _PyUnicode_To*
Andy Lester
report at bugs.python.org
Sat Feb 8 16:45:30 EST 2020
New submission from Andy Lester <andy at petdance.com>:
Four functions in Objects/unicodectype.c copy values out of lookup tables with a for loop
int i;
for (i = 0; i < n; i++)
res[i] = _PyUnicode_ExtendedCase[index + i];
instead of a memcpy
memcpy(res, &_PyUnicode_ExtendedCase[index], n * sizeof(Py_UCS4));
My Apple clang version 11.0.0 on my Mac optimizes away the for loop and generates equivalent code to the memcpy.
gcc 4.8.5 on my Linux box (the newest GCC I have) does not optimize away the loop.
The four functions are:
_PyUnicode_ToLowerFull
_PyUnicode_ToTitleFull
_PyUnicode_ToUpperFull
_PyUnicode_ToFoldedFull
----------
components: Unicode
messages: 361636
nosy: ezio.melotti, petdance, vstinner
priority: normal
severity: normal
status: open
title: Use memcpy() instead of for() loops in _PyUnicode_To*
type: performance
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39588>
_______________________________________
More information about the Python-bugs-list
mailing list