On Thu, 13 Feb 2014 10:03:50 -0800
Alec Warner <anta...@gentoo.org> wrote:

> On Thu, Feb 13, 2014 at 7:42 AM, Brian Dolbec <dol...@gentoo.org>
> wrote:
> 
> > well actually, for simple additions like that, string1 + string2,
> > it is actually faster.
> > But for multiple additions,  %s is much better, faster.  Also if the
> > string is translated, then use %s regardless.  That way the %s can
> > be moved around for the translation.
> >
> 
> In general we prefer % for readability purposes, not because it is
> faster.
> 
> foo = "Bar" + foo + " " + baz + "," + goat
> 
> foo = "Bar %s %s, %s" % (foo, baz, goat)
> 
> I think this case could go either way, because even with %,
> "NumberOf%s" is not much of an improvement.
> The code is littered with the former though, and it makes it really
> annoying to read ;)
> 
> -A

Do I have to sick Brian Harring on you ;)

I said for simple string addition... string1 + string2 is faster and
equally readable

Your example goes into the "string %s %s, %s" example where the string
substitution is actually faster.  Plus it is a lot more readable.


-- 
Brian Dolbec <dolsen>


Reply via email to