[PATCH 2 of 3] convert/mtn: use mtn "automate stdio" when available

Martin Geisler mg at aragost.com
Thu Mar 24 03:41:51 CDT 2011


Patrick Mézard <pmezard at gmail.com> writes:

> Le 23/03/11 20:24, daniel.atallah at gmail.com a écrit :
>
>> +            commandnbr += read
>
> Concatenating strings character by character is usually not a good
> idea performance-wise in python. It could be better to use a StringIO.
> That said you can let this for now, the use of a command server
> already makes thing much much faster.

CPython will do an in-place concatenation since Python 2.4, this is
mentioned right above this section:

  http://docs.python.org/library/stdtypes.html?highlight=quadratic#string-methods

However, as they also note, this is not to be depended on if you want
the same performance from other Python implementations. So if we're
talking about many strings, then I would use the normal idiom of
collecting them in a list first and then joining them at the end.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://aragost.com/en/services/mercurial/blog/


More information about the Mercurial-devel mailing list