[Tutor] optimization: faster than for

Alan Gauld alan.gauld at btinternet.com
Sun Jul 1 10:17:24 CEST 2007


"elis aeris" <hunter92383 at gmail.com> wrote `
>  oh yeah,  he said getdata()  but i don't know where it comes from

He told you it was a method of the image...

Another version of what you are doing uses a list comprehension
which might be slightly faster:

pixels = [image.getpixel((x,y)) for x in range(1024) for y in 
range(768)]

But your example didn't show you doing anything with the pixels you
retrieve, so just putting them in a list might not help!

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld





More information about the Tutor mailing list