Python name lookups

Steve Holden steve at holdenweb.com
Tue Oct 11 00:42:25 EDT 2005


Dave wrote:
> Hello All,
> 
> As far as I understand, Python deals with a lot of
> string objects, i.e. it looks up all names. Is there a
> way to find out how many name lookup operations take
> place in a Python program? Is it the name lookup
> operation or hash operation that degrades performance?
> What function does Python use for name lookup
> operations? Is it the lookdict function in
> Objects/dictobject.c?
> 
> Thank you for your help!
> 
Be aware that it doesn't "look up all names" if by that you mean that 
all variable accesses are symbolic. Function-local variables are 
referred to by a pre-computed offset in the stack frame, and so are much 
more quickly accessed than others, where the name-based access is 
typically used.

The only way I can think of to get the number you want is to instrument 
the interpreter once you have determined what you are really asking.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list