t...@thsu.org writes: > On Sep 2, 9:54 am, Bart Kastermans <bkast...@gmail.com> wrote: >> if d(a,b) == 1 and a < b: > > It will probably be faster if you reverse the evaluation order of that > expression. > > if a<b and d(a,b)==1: > > That way the d() function is called less than half the time. Of course > this assumes that a<b is a faster evaluation than d(a,b), but I think > that's true for your example. > -- > // T.Hsu
Indeed makes quite a difference, goes from 275 seconds down to 153 seconds. -- http://mail.python.org/mailman/listinfo/python-list