STINNER Victor <victor.stin...@gmail.com> added the comment:

>> 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.

----------

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

Reply via email to