Ma Lin <malin...@163.com> added the comment:
There are 4 functions have the similar code, see PR 16334. Just replaced the `unsigned long` type with `size_t` type, got these benchmarks. Can this be backported to 3.8 branch? 1. bytes.isascii() D:\dev\cpython\PCbuild\amd64\python.exe -m pyperf timeit -s "b = b'x' * 100_000_000; f = b.isascii;" "f()" +-----------+-----------+------------------------------+ | Benchmark | isascii_a | isascii_b | +===========+===========+==============================+ | timeit | 11.7 ms | 7.84 ms: 1.50x faster (-33%) | +-----------+-----------+------------------------------+ 2. bytes.decode('latin1') D:\dev\cpython\PCbuild\amd64\python.exe -m pyperf timeit -s "b = b'x' * 100_000_000; f = b.decode;" "f('latin1')" +-----------+----------+-----------------------------+ | Benchmark | latin1_a | latin1_b | +===========+==========+=============================+ | timeit | 60.3 ms | 57.4 ms: 1.05x faster (-5%) | +-----------+----------+-----------------------------+ 3. bytes.decode('ascii') D:\dev\cpython\PCbuild\amd64\python.exe -m pyperf timeit -s "b = b'x' * 100_000_000; f = b.decode;" "f('ascii')" +-----------+---------+-----------------------------+ | Benchmark | ascii_a | ascii_b | +===========+=========+=============================+ | timeit | 48.5 ms | 47.1 ms: 1.03x faster (-3%) | +-----------+---------+-----------------------------+ 4. bytes.decode('utf8') D:\dev\cpython\PCbuild\amd64\python.exe -m pyperf timeit -s "b = b'x' * 100_000_000; f = b.decode;" "f('utf8')" +-----------+---------+-----------------------------+ | Benchmark | utf8_a | utf8_b | +===========+=========+=============================+ | timeit | 48.3 ms | 47.1 ms: 1.03x faster (-3%) | +-----------+---------+-----------------------------+ ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38252> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com