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 <1380140762.59.0.0778893115079.issue19087@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2013-09-25 20:26:02pitrousetrecipients: + pitrou, vstinner, serhiy.storchaka
2013-09-25 20:26:02pitrousetmessageid: <1380140762.59.0.0778893115079.issue19087@psf.upfronthosting.co.za>
2013-09-25 20:26:02pitroulinkissue19087 messages
2013-09-25 20:26:02pitroucreate