A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-June/144920.html below:

[Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryview

[Python-Dev] PEP 467: Minor API improvements to bytes, bytearray, and memoryviewSerhiy Storchaka storchaka at gmail.com
Wed Jun 8 07:05:19 EDT 2016
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


More information about the Python-Dev mailing list

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