Differences between revisions 3 and 4
Revision 3 as of 2005-05-19 16:24:58
Size: 479
Editor: dhcp-130-65-200-92
Comment:
Revision 4 as of 2005-07-28 08:53:30
Size: 618
Editor: 158
Comment:
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:


----
On the win32 Python 2.4 I'm seeing the join sample above complete in less than half the time of the concatenating sample.
 -db

Counter to the PythonSpeed/PerformanceTips, on python 2.4 the following string concatenation is almost twice as fast:

   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:

   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


On the win32 Python 2.4 I'm seeing the join sample above complete in less than half the time of the concatenating sample.

  • -db

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.