summaryrefslogtreecommitdiffstats
path: root/Python/Python-tokenize.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-05-28 16:05:20 (GMT)
committerGitHub <noreply@github.com>2024-05-28 16:05:20 (GMT)
commit0518edc17049a2f474b049b7d7fe3ef4339ceb83 (patch)
tree19d3112f06d2466cac1751e4109c9f551d81709f /Python/Python-tokenize.c
parent2da0dc094fa855ed4df251aab58b6f8a2b6969a1 (diff)
downloadcpython-0518edc17049a2f474b049b7d7fe3ef4339ceb83.zip
cpython-0518edc17049a2f474b049b7d7fe3ef4339ceb83.tar.gz
cpython-0518edc17049a2f474b049b7d7fe3ef4339ceb83.tar.bz2
gh-119396: Optimize unicode_repr() (#119617)
Use stringlib to specialize unicode_repr() for each string kind (UCS1, UCS2, UCS4). Benchmark: +-------------------------------------+---------+----------------------+ | Benchmark | ref | change2 | +=====================================+=========+======================+ | repr('abc') | 100 ns | 103 ns: 1.02x slower | +-------------------------------------+---------+----------------------+ | repr('a' * 100) | 369 ns | 369 ns: 1.00x slower | +-------------------------------------+---------+----------------------+ | repr(('a' + squote) * 100) | 1.21 us | 946 ns: 1.27x faster | +-------------------------------------+---------+----------------------+ | repr(('a' + nl) * 100) | 1.23 us | 907 ns: 1.36x faster | +-------------------------------------+---------+----------------------+ | repr(dquote + ('a' + squote) * 100) | 1.08 us | 858 ns: 1.25x faster | +-------------------------------------+---------+----------------------+ | Geometric mean | (ref) | 1.16x faster | +-------------------------------------+---------+----------------------+
Diffstat (limited to 'Python/Python-tokenize.c')
0 files changed, 0 insertions, 0 deletions