[Python-ideas] caching properties

Ben Finney ben+python at benfinney.id.au
Fri May 1 01:37:37 CEST 2009


George Sakkis <george.sakkis at gmail.com>
writes:

> I think It's clear by now that caching in the general case is not
> trivial, both in terms of API and implementation. That makes the
> original request - caching properties only - more appealing since most
> problems go away if there are no parameters.

Nevertheless, the “memoize” pattern *is* well-understood, and already
implemented for Python as discussed earlier. It covers the “cached
property” as a degenerate (i.e. simpler) case. Making a specific
decorator that *only* addresses “cached property” is too narrow, IMO.

I think a “memoize” decorator (by whatever name) is the right level of
generality to address this use case, and has the advantage of existing
implementations.

-- 
 \     “As I bit into the nectarine, it had a crisp juiciness about it |
  `\          that was very pleasurable - until I realized it wasn't a |
_o__)               nectarine at all, but A HUMAN HEAD!!” —Jack Handey |
Ben Finney




More information about the Python-ideas mailing list