[Tutor] loop performance in global namespace (python-2.6.1)

spir denis.spir at free.fr
Thu Mar 12 16:41:17 CET 2009


Le Thu, 12 Mar 2009 11:13:33 -0400,
Kent Johnson <kent37 at tds.net> 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__()).

? I thought this was mainly because a name has first to be searched (unsuccessfully) locally before a global lookup is launched.
Also, are locals really stored in an array? How does lookup then proceed? Is it a kind of (name,ref) sequence?

Denis
------
la vita e estrany



More information about the Python-list mailing list