speedup up dictionary access

William Park parkw at better.net
Sat May 12 17:50:47 EDT 2001


On Sat, May 12, 2001 at 05:21:32PM -0400, Roy Smith wrote:
>    if (self.cache.has_key (name) and self.cache[name]) or self.check (name):
>       do stuff
> 
> check() returns 0 or 1 based on the value of name, and also inserts this 
> value into the cache.

Just checking... only if cache[name] is 0 or does not exist, right?

> Which is faster?

Try both.

--William Park, Open Geometry Consulting, Mississauga, Ontario, Canada.
  8 CPU cluster, (Slackware) Linux, Python, LaTeX, vim, mutt




More information about the Python-list mailing list