Antoine Pitrou added the comment:

Here is a patch. Benchmarks (under Linux where realloc is fast; the gap may be 
wider under Windows):

$ ./python -m timeit "b=bytearray(100000)" "while b: b[:1] = b''"
-> before: 225 msec per loop
-> after: 60.4 msec per loop

$ ./python -m timeit "b=bytearray(100000)" "while b: b[:200] = b''"
-> before: 1.17 msec per loop
-> after: 350 usec per loop

----------
keywords: +patch
nosy: +haypo
Added file: http://bugs.python.org/file31873/bytea_slice.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19087>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to