"H J van Rooyen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Paul McGuire" <[EMAIL PROTECTED]> wrote: > > | Even downer-and-dirtier, you could approximate 30 with 32, 59 with 64, and > | 11 with 8, and do bit-shifting instead of multiplying: > | > | def darkness(img,x,y): > | return (RedVal(img,x,y) << 5) + (GreenVal(img,x,y) << 6) + > | (BlueVal(img,x,y) << 3) > | > | > | -- Paul > > *grin* - a man after my own heart! - how do you multiply by ten? - shift, save a > copy, shift twice more and add the copy... > > - Hendrik > Sadly, my timeit results show this saves only a little time, and shift-copy-shiftsomemore-and-add is even slower then just doing the original floating point multiply. The biggest win is in prelookup of Image.GetXXX functions.
-- Paul -- http://mail.python.org/mailman/listinfo/python-list