Author malin
Recipients malin, methane, serhiy.storchaka, sir-sigurd
Date 2019-09-23.14:52:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569250342.98.0.649478345933.issue38252@roundup.psfhosted.org>
In-reply-to
Content
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%) |
+-----------+---------+-----------------------------+
History
Date User Action Args
2019-09-23 14:52:23malinsetrecipients: + malin, methane, serhiy.storchaka, sir-sigurd
2019-09-23 14:52:22malinsetmessageid: <1569250342.98.0.649478345933.issue38252@roundup.psfhosted.org>
2019-09-23 14:52:22malinlinkissue38252 messages
2019-09-23 14:52:22malincreate