List comprehension timing difference.
bkasterm at gmail.com
Fri Sep 2 22:15:11 EDT 2011
ting at thsu.org writes:
> On Sep 2, 9:54 am, Bart Kastermans <bkast... at gmail.com> wrote:
>> if d(a,b) == 1 and a < b:
> It will probably be faster if you reverse the evaluation order of that
> 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
More information about the Python-list