Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
I do not have other benchmarks. memoryview was just one of few builtins which still use PyArg_ParseTupleAndKeywords() and I know how inefficient it is. Since Argument Clinic was already used for memoryview.hex() I did not see problems with converting the rest of memoryview methods to Argument Clinic. Microbenchmarks: $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "b = b'abcdefgh'" "memoryview(b)" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 187 ns +- 6 ns -> [/home/serhiy/py/cpython-release2/python] 144 ns +- 4 ns: 1.30x faster (-23%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "b = b'abcdefgh'" "memoryview(object=b)" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 312 ns +- 7 ns -> [/home/serhiy/py/cpython-release2/python] 210 ns +- 6 ns: 1.49x faster (-33%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = memoryview(b'abcdefgh')" "m.cast('I')" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 167 ns +- 4 ns -> [/home/serhiy/py/cpython-release2/python] 104 ns +- 2 ns: 1.60x faster (-38%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = memoryview(b'abcdefgh')" "m.cast(format='I')" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 331 ns +- 6 ns -> [/home/serhiy/py/cpython-release2/python] 153 ns +- 7 ns: 2.16x faster (-54%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = memoryview(b'abcdefgh')" "m.cast('B', (2, 2, 2))" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 229 ns +- 5 ns -> [/home/serhiy/py/cpython-release2/python] 154 ns +- 4 ns: 1.48x faster (-32%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = memoryview(b'abcdefgh')" "m.cast(format='B', shape=(2, 2, 2))" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 494 ns +- 11 ns -> [/home/serhiy/py/cpython-release2/python] 198 ns +- 5 ns: 2.49x faster (-60%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = memoryview(b'abcdefgh')" "m.tobytes()" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 90.3 ns +- 3.2 ns -> [/home/serhiy/py/cpython-release2/python] 65.8 ns +- 1.9 ns: 1.37x faster (-27%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = memoryview(b'abcdefgh')" "m.tobytes('C')" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 183 ns +- 6 ns -> [/home/serhiy/py/cpython-release2/python] 129 ns +- 4 ns: 1.41x faster (-29%) $ ./python -m pyperf timeit -q --compare-to=../cpython-release/python -s "m = memoryview(b'abcdefgh')" "m.tobytes(order='C')" Mean +- std dev: [/home/serhiy/py/cpython-release/python] 340 ns +- 11 ns -> [/home/serhiy/py/cpython-release2/python] 174 ns +- 5 ns: 1.96x faster (-49%) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41262> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com