On Thu, Mar 12, 2009 at 11:41 AM, spir wrote:
> Le Thu, 12 Mar 2009 11:13:33 -0400,
> Kent Johnson s'exprima ainsi:
>
>> Because local name lookup is faster than global name lookup. Local
>> variables are stored in an array in the stack frame and accessed by
>> index. Global names are stored in a
Le Thu, 12 Mar 2009 11:13:33 -0400,
Kent Johnson s'exprima ainsi:
> Because local name lookup is faster than global name lookup. Local
> variables are stored in an array in the stack frame and accessed by
> index. Global names are stored in a dict and accessed with dict access
> (dict.__getitem__
On Thu, Mar 12, 2009 at 8:13 AM, Poor Yorick
wrote:
> In the following snippet, the loop in the global namespace takes twice as
> long
> as the loop in the function namespace. Why?
Because local name lookup is faster than global name lookup. Local
variables are stored in an array in the stack fr
In the following snippet, the loop in the global namespace takes twice as long
as the loop in the function namespace. Why?
limit = 5000
def f1():
counter = 0
while counter < limit:
counter += 1
time1 = time.time()
f1()
print(time.time() - time