Glyph Lefkowitz added the comment:

On Jan 22, 2013, at 1:46 PM, STINNER Victor <rep...@bugs.python.org> wrote:

> 2013/1/22 Guido van Rossum <rep...@bugs.python.org>:
>> Twisted still would like to see this.
> 
> Sorry, but this argument doesn't convince me. A better argument is
> that bytes+bytes+...+bytes is inefficient: it creates a lot of
> temporary objects instead of computing the final size directly, or
> using realloc.

Uh, yes.  That's one of the reasons (given above) that Twisted would still like 
to see this.  It seemed to me that Guido was stating a fact there, not making 
an argument.  The Twisted project *would* like to see this, I can assure you, 
regardless of whether you're convinced or not :).

> str%args and str.format() uses realloc() and overallocates its
> internal buffer to avoid too many calls to realloc().

More importantly, it's fairly easy to add many optimizations of this type to an 
API in the style of .format(), even if it's not present in the first round; 
optimizing bytes + bytes + bytes requires slightly scary interactions with 
refcounting and potentially GC, like the += optimization.  The API just has 
more information to go on, and that's a good thing.

----------

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

Reply via email to