[issue41262] Convert memoryview to Argument Clinic
Stefan Krah
report at bugs.python.org
Sat Jul 18 05:04:07 EDT 2020
Stefan Krah <stefan at bytereef.org> added the comment:
I cannot detect a speedup in test_buffer, which is a heavy user of memoryviews:
# before:
>>> a = [3.742, 3.589, 3.542, 3.495, 3.481, 3.620, 3.773, 3.755, 3.701, 3.661]
>>> sum(a) / 10
3.6358999999999995
# after
>>> b = [3.63, 3.596, 3.475, 3.43, 3.792, 3.58, 3.810, 3.52, 3.55, 3.690]
>>> sum(b) / 10
3.6072999999999995
A microbenchmark shows a speedup:
# before:
$ ./python -m timeit -s "b = b'1234567890'" "memoryview(b)"
2000000 loops, best of 5: 116 nsec per loop
# after:
./python -m timeit -s "b = b'1234567890'" "memoryview(b)"
5000000 loops, best of 5: 98 nsec per loop
As the original author, I'm not sure why I should put up with the
less readable code for such a gain. For decimal I'm using the pi
benchmark, which, while small, is at least a real math function in
pure Python.
Do you have other benchmarks?
----------
status: closed -> open
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41262>
_______________________________________
More information about the Python-bugs-list
mailing list