➜

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 vstinner
Recipients kristjan.jonsson, loewis, pitrou, python-dev, serhiy.storchaka, vstinner
Date 2012-05-03.21:42:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1336081368.68.0.774804478777.issue14687@psf.upfronthosting.co.za>
In-reply-to
Content
>> because I read that realloc() on Windows is not efficient.
> Efficiency is not a Boolean property, you know :)  Anyway,
> I´d be surprised if it were very iniefficient, given that
> the heap allocators on Windows are quite mature by now.

My benchmark is more a *micro* benchmark on some very basic cases (short ASCII strings). But it looks like overallocating *helps*. In the following example, only two resize are needed:

./python -m timeit \
    -s 'N=200; L=3; fmt="%s"*N; args=("a"*L,)*N' \
    'fmt % args'

len(fmt)+100 = 500 characters are allocated for the initial buffer. Writing the 501st character enlarges the buffer to 626 characters: first resize. The output string is truncated to 600 characters: second and final resize.
History
Date User Action Args
2012-05-03 21:42:48vstinnersetrecipients: + vstinner, loewis, pitrou, kristjan.jonsson, python-dev, serhiy.storchaka
2012-05-03 21:42:48vstinnersetmessageid: <1336081368.68.0.774804478777.issue14687@psf.upfronthosting.co.za>
2012-05-03 21:42:48vstinnerlinkissue14687 messages
2012-05-03 21:42:48vstinnercreate