Python example: possible speedup?

Moshe Zadka moshez at server.python.net
Thu Sep 9 01:42:24 EDT 1999


Note an important speed-up in concatenating strings: use cStringIO:

a=cStringIO.StringIO()
for i in range(10000):
	a.write('h')
a=a.getvalue()

rather then:

a=''
for  i in range(10000):
	a=a+'h'






More information about the Python-list mailing list