[Tutor] Astonishing timing result

Kent Johnson kent37 at tds.net
Wed Jun 25 02:35:33 CEST 2008


On Tue, Jun 24, 2008 at 5:20 PM, Dick Moores <rdm at rcblue.com> wrote:

> Basically, I'm not worried, just curious. Not about the small differences,
> but why did the use of the standard    if __name__ == '__main__'     result
> it such speed?

Because __name__ is not equal to "__main__", so you were basically
skipping the whole test. The most common cause of unexpected timing
results is tests that don't do what you think they do.

The test code is not run in the main module. You can dig into the
timeit module if you want the details.

> Am I not doing the timing correctly?

Right.

Kent


More information about the Tutor mailing list