[Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview
Paul Sokolovsky
pmiscml at gmail.com
Wed Jun 8 08:11:47 EDT 2016
More information about the Python-Dev mailing list
Wed Jun 8 08:11:47 EDT 2016
- Previous message (by thread): [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview
- Next message (by thread): [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello, On Wed, 8 Jun 2016 14:45:22 +0300 Serhiy Storchaka <storchaka at gmail.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. -- Best regards, Paul mailto:pmiscml at gmail.com
- Previous message (by thread): [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview
- Next message (by thread): [Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list