Author glyph
Recipients arjennienhuis, benjamin.peterson, christian.heimes, eric.smith, exarkun, ezio.melotti, glyph, gvanrossum, loewis, martin.panter, pitrou, serhiy.storchaka, terry.reedy, uau, vstinner
Date 2013-01-22.22:51:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <D185A1EC-B191-41F8-993A-39EDE3CE3436@twistedmatrix.com>
In-reply-to <CAMpsgwbdHP=7QsewMZzfagv=xHs88Xjq7PnJxb+mGaoQmsWPcg@mail.gmail.com>
Content
On Jan 22, 2013, at 1:46 PM, STINNER Victor <report@bugs.python.org> wrote:

> 2013/1/22 Guido van Rossum <report@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.
History
Date User Action Args
2013-01-22 22:51:03glyphsetrecipients: + glyph, gvanrossum, loewis, terry.reedy, exarkun, pitrou, vstinner, eric.smith, christian.heimes, benjamin.peterson, ezio.melotti, arjennienhuis, uau, martin.panter, serhiy.storchaka
2013-01-22 22:51:03glyphlinkissue3982 messages
2013-01-22 22:51:03glyphcreate