[Tutor] [Fwd: Re: Astonishing timing result]

Marilyn Davis marilyn at deliberate.com
Wed Jun 25 04:02:52 CEST 2008


On Tue, June 24, 2008 5:52 pm, Dick Moores wrote:

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

Ah.

So the difference we see is the whole sort.  That makes sense.

Thank you for the understanding.

Has anyone ever timed the difference between using a function that was
imported with:

from my_module import MyFunction

and:

import my_module

and then my_module.MyFunction()

Also, if anyone is still wondering, a "code block" is the stuff that is
indented.  The stuff between a ':' and the unindent.

Marilyn Davis

>
>
>> 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
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor






More information about the Tutor mailing list