On Thu, 31 Jan 2008 20:05:44 +0000, Stargaming wrote: > String concatenation is generally considered unpythonic, better use > string interpolation:: > > 'H> %s' % (M,)
String concatenation is significantly faster than string interpolation. >>> import timeit >>> timeit.Timer("'H> %s' % M", "M = 'abcdef'").repeat() [1.3407769203186035, 0.69128704071044922, 0.56362509727478027] >>> timeit.Timer("'H> ' + M", "M = 'abcdef'").repeat() [0.69647812843322754, 0.69620108604431152, 0.65643787384033203] The danger with string concatenation comes from building up a string piece by piece: even though a single + is faster than a single %, a dozen concats will likely be MUCH slower than a single &. Also, the tuple above is totally unnecessary. 'H> %s' % M will work fine. -- Steven -- http://mail.python.org/mailman/listinfo/python-list