Inada Naoki <songofaca...@gmail.com> added the comment: This optimization is only for short strings. There is no significant difference for long and non-ASCII strings.
``` # 1000 ASCII $ ./python -m pyperf timeit --compare-to=./python-master -s 'b=b"f"*1000' -- 'b.decode()' python-master: ..................... 196 ns +- 1 ns python: ..................... 185 ns +- 1 ns Mean +- std dev: [python-master] 196 ns +- 1 ns -> [python] 185 ns +- 1 ns: 1.06x faster (-6%) # 10000 ASCII $ ./python -m pyperf timeit --compare-to=./python-master -s 'b=b"f"*10000' -- 'b.decode()' python-master: ..................... 671 ns +- 4 ns python: ..................... 662 ns +- 1 ns Mean +- std dev: [python-master] 671 ns +- 4 ns -> [python] 662 ns +- 1 ns: 1.01x faster (-1%) # 100000 ASCII $ ./python -m pyperf timeit --compare-to=./python-master -s 'b=b"f"*100000' -- 'b.decode()' python-master: ..................... 5.86 us +- 0.03 us python: ..................... 5.85 us +- 0.02 us Mean +- std dev: [python-master] 5.86 us +- 0.03 us -> [python] 5.85 us +- 0.02 us: 1.00x faster (-0%) # 1 non-ASCII $ ./python -m pyperf timeit --compare-to=./python-master -s 'b="あ".encode()' -- 'b.decode()' python-master: ..................... 138 ns +- 2 ns python: ..................... 136 ns +- 2 ns Mean +- std dev: [python-master] 138 ns +- 2 ns -> [python] 136 ns +- 2 ns: 1.02x faster (-2%) # 1000 ASCII + 1 non-ASCII $ ./python -m pyperf timeit --compare-to=./python-master -s 'b=b"x"*1000 + "あ".encode()' -- 'b.decode()' python-master: ..................... 361 ns +- 9 ns python: ..................... 360 ns +- 5 ns Mean +- std dev: [python-master] 361 ns +- 9 ns -> [python] 360 ns +- 5 ns: 1.00x faster (-0%) Not significant! # 10000 ASCII + 1 non-ASCII $ ./python -m pyperf timeit --compare-to=./python-master -s 'b=b"x"*10000 + "あ".encode()' -- 'b.decode()' python-master: ..................... 2.83 us +- 0.02 us python: ..................... 2.83 us +- 0.03 us Mean +- std dev: [python-master] 2.83 us +- 0.02 us -> [python] 2.83 us +- 0.03 us: 1.00x slower (+0%) Not significant! ``` ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37348> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com