On 08.06.16 13:37, Paul Sokolovsky wrote: >> The obvious way to create the bytes object of length n is b'\0' * n. > > That's very inefficient: it requires allocating useless b'\0', then a > generic function to repeat arbitrary memory block N times. If there's a > talk of Python to not be laughed at for being SLOW, there would rather > be efficient ways to deal with blocks of binary data. Do you have any evidences for this claim? $ ./python -m timeit -s 'n = 10000' -- 'bytes(n)' 1000000 loops, best of 3: 1.32 usec per loop $ ./python -m timeit -s 'n = 10000' -- 'b"\0" * n' 1000000 loops, best of 3: 0.858 usec per loop
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4