On Aug 11, 3:03 pm, maestro <[EMAIL PROTECTED]> wrote: > If isMult is slow then: > > if len(str(a)) == len(str(r)) and isMult(a, r): > trues.append((a, r)) > > will be much faster than: > > if isMult(a, r) and len(str(a)) == len(str(r)): > trues.append((a, r)) > > right? seems obvious but there is no magic going on that wouldn't > make this true right?
Once a failed condition is met the rest are skipped for evaluation. Whether or not that saves you any reasonable amount of time would be up to the various tests being used with your conditions. If your function isMult is just doing the same work as "if not a % r" then that would be faster than casting your integers/floats to a string and testing their length imo. You could always go through the trouble of profiling your code with separate if statements to see how much time is spent on each, also note your mean failure rate for each conditional test and then decide for yourself which to place first. Hope that helps, Chris -- http://mail.python.org/mailman/listinfo/python-list