Speed issues

Gerrit Holl gerrit.holl at pobox.com
Mon Dec 27 08:35:47 EST 1999


Hello,

is an assigment slower than appending to a list?
If I've got this function:

def f(s):
 o=[]
 for c in s:
  o.append(chr(ord(c)/2))
 return string.join(o, '')

or:

def f(s):
 o=''
 for c in s:
  o = o + chr(ord(c)/2) 
 return o

What is faster? What do you prefer?

regards,
Gerrit.

-- 
"However, complexity is not always the enemy."

  -- Larry Wall (Open Sources, 1999 O'Reilly and Associates)
  2:25pm  up  4:51, 12 users,  load average: 0.23, 0.11, 0.03




More information about the Python-list mailing list