[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] converting byte image for display



Ouch!

def to_bw(rawbuffer):
   retstr=''
   for e in rawbuffer :
       retstr = retstr + e*3
   return retstr

This is a typical slow usage of string concat.
the same loop would be much quicker execute like this

bwbuffer = "".join(map(lambda x:x*3,rawbuffer))

Guillaume