Python 2 times slower than Perl

Christopher A. Craig com-nospam at ccraig.org
Tue Jul 17 23:12:23 CEST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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.

- -- 
Christopher A. Craig <com-nospam at ccraig.org>
"Tragedy is when I cut my finger.  Comedy is when you fall in an open
sewer and die."  Mel Brooks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt

iEYEARECAAYFAjtUqjcACgkQjVztv3T8pzsrTQCfRDCvNaHn8NhnHWUu1j42vI1i
7DQAoKg0+pweTRul6FdtfM7Et4xOKDs6
=3wsl
-----END PGP SIGNATURE-----



More information about the Python-list mailing list