Python 2 times slower than Perl

Bjorn Pettersen BPettersen at NAREX.com
Tue Jul 17 17:36:09 EDT 2001


> From: Christopher A. Craig [mailto:com-nospam at ccraig.org]
> 
> Erno Kuusela <erno-news at erno.iki.fi> writes:
> 
> > if you put the code in a function, it will be a fair bit faster
> > since global variable access is slower than local variable access.
> 
> This is, in this case, incorrect.  Unless I am horribly mistaken, the
> higher cost of dealing with globals is that you first have to do a
> failed lookup in the local dictionary.  (Plus failed lookups are more
> expensive than successful ones)  
> 
> In this particular case the local dictionary is the same as the global
> one, so I don't see how moving to a function would offer a 
> time savings.

Actually, it increases performance by ~15%.

-- bjorn




More information about the Python-list mailing list