speedup up dictionary access

Darrell news at dorb.com
Sat May 12 19:28:31 EDT 2001


Last I checked exceptions are slower than "if--else"
For 2.0+ try this:

var = self.cache.get(name)
if var != None:
    do stuff

--Darrell

"Roy Smith" <roy at panix.com> wrote
>
>    try:
>       if self.cache[name]:
>          do stuff
>    except KeyError:
>       if self.check (name):
>          do stuff
>






More information about the Python-list mailing list