"Gabriel Genellina" writes:
> En Fri, 03 Jun 2011 21:02:56 -0300, Nobody escribió:
>
> > 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:
> >
> > The general concept is called "m
En Fri, 03 Jun 2011 21:02:56 -0300, Nobody escribió:
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:
The general concept is called "memoization". There isn't an
implementation
in th
Hi,
Many thanks for everyone's explanations and pointers!
thanks!
Wilbert Berendsen
--
http://www.wilbertberendsen.nl/
"You must be the change you wish to see in the world."
-- Mahatma Gandhi
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney writes:
> It's best to implement Memoize as a Python decorator in one place
> http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize>.
Michele Simionato discusses a better implementation of a Memoize
decorator in the documentation for his useful ‘decorator’ library
http://micheles
Wilbert Berendsen writes:
> I find myself all over the place associating objects with each other using
> dicts as caches:
>
> something like this:
>
> _cache = {}
>
> def get_something(obj):
> """Returns the frobnicate-plugin for the specified object."""
> try:
> return _cache[ob
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 con
self.func = func
def __missing__(self, key):
res = self[key] = self.func(key)
return res
Are there other peoply using things like this? Is there a solution like this
in the standard lib that I'm overlooking? Of course 'except KeyError'
everywhere is not re