[Tutor] Astonishing timing result

Kent Johnson kent37 at tds.net
Wed Jun 25 10:30:17 CEST 2008


On Wed, Jun 25, 2008 at 1:16 AM, Dick Moores <rdm at rcblue.com> wrote:
> At 07:00 PM 6/24/2008, Marilyn Davis wrote:
>
>> Has anyone ever timed the difference between using a function that was
>> imported with:
>>
>> from my_module import MyFunction
>>
>> and:
>>
>> import my_module
>
> Here are 2 comparisons: <http://py77.python.pastebin.com/f53ab3769>, and
>  <http://py77.python.pastebin.com/f68346b28>
>
> I don't see a significant difference.

I wouldn't expect much. The only difference is the extra attribute
lookup in the second form. Attribute lookup is slow enough to be
measurable and fast enough that you will only care if you are doing it
a lot of times.

Kent


More information about the Tutor mailing list