[Tutor] Questions about PIL

Luke Paireepinart rabidpoobear at gmail.com
Thu Nov 9 08:31:03 CET 2006

Chris Hengge wrote:
> alist = difference(image1,image2)
> a = [b for b in alist.getdata() if b != (0,0,0)]
> if len(a) != 0:
>    print "Not the same"
> is much slower then (9x)
> if im1.tostring() != im2.tostring()
>        print "something changed!"
> This loop itself is fairly slow by itself though.. I'm going to try 
> and see if there is a faster way.
are you sure you know what a loop is?
The only loop here is in the list comprehension.
'if' is not a loop.
'for' and 'while' are.
In computer science, it's important to be clear in your use of terminology.

It makes sense that my example was slow.
I didn't really think to try converting them to strings.

Any time you're trying to compare pixel values, it's going to take a while,
cause remember, a 1024X768 image has 786,432 different pixels.
I think your tostring comparison may be your best bet.

More information about the Tutor mailing list