Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6983

Re: except KeyError, everywhere

From Nobody <nobody@nowhere.com>
Subject Re: except KeyError, everywhere
Date 2011-06-04 01:02 +0100
Message-Id <pan.2011.06.04.00.02.48.625000@nowhere.com>
Newsgroups comp.lang.python
References <mailman.2437.1307132130.9059.python-list@python.org>
Organization Zen Internet

Show all headers | View raw


On Fri, 03 Jun 2011 22:08:16 +0200, Wilbert Berendsen wrote:

> I find myself all over the place associating objects with each other using 
> dicts as caches:

> Are there other peoply using things like this? Is there a solution like
> this in the standard lib that I'm overlooking?

The general concept is called "memoization". There isn't an implementation
in the standard library, but you'll find plenty of examples, e.g. (from
the first page of Google hits for "python memoization"):

http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
http://code.activestate.com/recipes/52201-memoizing-cacheing-function-return-values/
http://code.activestate.com/recipes/577219-minimalistic-memoization/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

except KeyError, everywhere Wilbert Berendsen <wbsoft@xs4all.nl> - 2011-06-03 22:08 +0200
  Re: except KeyError, everywhere Nobody <nobody@nowhere.com> - 2011-06-04 01:02 +0100
    Re: except KeyError, everywhere --> memoization Wilbert Berendsen <wbsoft@xs4all.nl> - 2011-06-05 00:27 +0200
    Re: except KeyError, everywhere "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-06-07 00:45 -0300
      Re: except KeyError, everywhere Ben Finney <ben+python@benfinney.id.au> - 2011-06-07 14:08 +1000
  Re: except KeyError, everywhere Ben Finney <ben+python@benfinney.id.au> - 2011-06-04 10:03 +1000
    Re: except KeyError, everywhere Ben Finney <ben+python@benfinney.id.au> - 2011-06-04 10:37 +1000

csiph-web