On 12.10.16 08:03, Nathaniel Smith wrote:
On Tue, Oct 11, 2016 at 9:08 PM, INADA Naoki <songofaca...@gmail.com> wrote:
From Python 3.4, bytearray is good solution for I/O buffer, thanks to
#19087 [1].
Actually, asyncio uses bytearray as I/O buffer often.

Whoa what?! This is awesome, I had no idea that bytearray had O(1)
deletes at the front. I literally reimplemented this myself on type of
bytearray for some 3.5-only code recently because I assumed bytearray
had the same asymptotics as list, and AFAICT this is totally
undocumented. Shouldn't we write this down somewhere? Maybe here? ->
https://docs.python.org/3/library/functions.html#bytearray

I afraid this is CPython implementation detail (like string concatenation optimization). Other implementations can have O(N) deletes at the front of bytearray.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to