On Wed, 8 Jun 2016 14:45:22 +0300 Serhiy Storchaka email@example.com wrote:
$ ./run-bench-tests bench/bytealloc* bench/bytealloc: 3.333s (+00.00%) bench/bytealloc-1-bytes_n.py 11.244s (+237.35%) bench/bytealloc-2-repeat.py
If the performance of creating an immutable array of n zero bytes is important in MicroPython, it is worth to optimize b"\0" * n.
No matter how you optimize calloc + something, it's always slower than just calloc.
For now CPython is the main implementation of Python 3
Indeed, and it already has bytes(N). So, perhaps nothing should be done about it except leaving it alone. Perhaps, more discussion should go into whether there's need for .iterbytes() if there's [i:i+1] already. (I personally skip that, as I find [i:i+1] perfectly ok, and while I can't understand how people may be not ok with it up to wanting something more, I leave such possibility).
and bytes(n) is slower than b"\0" * n in CPython.