Differences between revisions 1 and 2
Revision 1 as of 2005-05-19 16:22:08
Size: 522
Editor: dhcp-130-65-200-92
Comment:
Revision 2 as of 2005-05-19 16:22:43
Size: 468
Editor: dhcp-130-65-200-92
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Line 5: Line 4:
# Code is Public Domain.
Line 20: Line 18:
# Code is Public Domain.

Counter to the performance guide on python 2.4 the following string concatenation is almost twice as fast:

Toggle line numbers
   1 from time import time
   2 t = time()
   3 
   4 s = 'lksdajflakjdsflku09uweoir'
   5 for x in range(40):
   6     s += s[len(s)/2:]
   7     
   8 print 'duration:', time()-t

as:

Toggle line numbers
   1 from time import time
   2 t = time()
   3 
   4 s = 'lksdajflakjdsflku09uweoir'
   5 for x in range(40):
   6     s = "".join((s, s[len(s)/2:]))
   7     
   8 print 'duration:', time()-t

ConcatenationTestCode (last edited 2012-06-28 11:33:35 by cpe-24-24-211-202)

Unable to edit the page? See the FrontPage for instructions.