[Tutor] Astonishing timing result

Dick Moores rdm at rcblue.com
Wed Jun 25 02:52:17 CEST 2008


At 05:35 PM 6/24/2008, Kent Johnson wrote:
>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.

Ah.

>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.

OK, I'll dig.

Thanks,

Dick 



More information about the Tutor mailing list