This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients pitrou, serhiy.storchaka, vstinner
Date 2013-09-25.20:26:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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
Date User Action Args
2013-09-25 20:26:02pitrousetrecipients: + pitrou, vstinner, serhiy.storchaka
2013-09-25 20:26:02pitrousetmessageid: <>
2013-09-25 20:26:02pitroulinkissue19087 messages
2013-09-25 20:26:02pitroucreate