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/2010-October/104933.html below:

[Python-Dev] new buffer in python2.7

[Python-Dev] new buffer in python2.7 [Python-Dev] new buffer in python2.7Antoine Pitrou solipsis at pitrou.net
Wed Oct 27 13:15:42 CEST 2010
> >Here are micro-benchmarks under 3.2:
> 
> > $ ./python -m timeit -s "x = b'x'*10000" "x[:100]"
> > 10000000 loops, best of 3: 0.134 usec per loop
> > $ ./python -m timeit -s "x = memoryview(b'x'*10000)" "x[:100]"
> > 10000000 loops, best of 3: 0.151 usec per loop
> 
> That's weird.  The greedy slice needs two memory allocations.  One for
> the ByteArray object itself, one for its cargo.  In total, more that
> 100 bytes.  In contrast, creating the MemoryView object requires only
> one allocation of a few dozen bytes.

It's not a bytearray object, it's a bytes object. It requires only a
single allocation since the data is allocated inline.
The memoryview object must also call getbuffer() again on the original
object.

Regards

Antoine.


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