Fastest Way To Loop Through Every Pixel

Paul McGuire ptmcg at austin.rr._bogus_.com
Fri Jul 28 01:44:02 EDT 2006


"Nick Vatamaniuc" <vatamane at gmail.com> wrote in message
news:1154053874.100840.122250 at p79g2000cwp.googlegroups.com...
> Hello Chaos,
>
> Then of course if you do the whole thing many times you could just
> pre-generate the indices as in:
> all_indices=[]
> for i in xrange(thisHeight):
>   for j in xrange(thisWidth):
>      all_indices.append( (i,j) )
>

Or just:

all_indices = [ (i,j) for i in xrange(thisHeight) for j in
xrange(thisWidth) ]

Embrace those list comprehensions!

-- Paul





More information about the Python-list mailing list