[CentralOH] Python interpretor question

Mark Erbaugh mark at microenh.com
Thu Apr 21 20:15:51 CEST 2011


On Apr 21, 2011, at 10:02 AM, William McVey wrote:

> On Wed, 2011-04-20 at 20:35 -0400, Eric Floehr wrote:
>> One million executions of f1 to 0.65 seconds on my machine, f2 took
>> 0.62 seconds.  This holds regardless if I test f2 or f1 first, etc.
>> 
>> 
>> So Jon's thought that the local variable create/destroy weighing down
>> f1 more than the time benefit of a function-space lookup seems to
>> hold.
>> 
> I'd warn about extrapolating too much from this one limited example.
> Although the creation of a single use variable multiple times within the
> function caused f1 to take more computation than f2, if the variable is
> referenced more than just once, the value of a local lookup within the
> function's namespace will begin to shine through and "pay off" the
> variable's creation cost. Some simplistic testing showed that after 3
> lookups within the functions, f1 began running faster than f2.
> 
>  -- William

Good analysis. Thanks.

Mark


More information about the CentralOH mailing list