mirror of
https://github.com/python/cpython.git
synced 2026-02-05 17:35:34 +00:00
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 |
+-------------------------------------+---------+----------------------+
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| __main__.py | ||
| _analyzer.py | ||
| _builtin_types.py | ||
| _capi.py | ||
| _files.py | ||
| _parser.py | ||
| globals-to-fix.tsv | ||
| ignored.tsv | ||
| known.tsv | ||