[Python-ideas] caching properties
ben+python at benfinney.id.au
Thu Apr 30 07:24:26 CEST 2009
Benjamin Peterson <benjamin at python.org>
> I think it would be nice to add a "cache" argument to the property()
> constructor. When "cache" was True, property would only ask the getter
> function once for the result. This would simplify properties that
> require expensive operations to compute.
I would prefer this as a decorator (not affecting the function
signature), and applicable to any function (not just a property).
This is the “memoize” pattern, implemented as a decorator in
\ Lucifer: “Just sign the Contract, sir, and the Piano is yours.” |
`\ Ray: “Sheesh! This is long! Mind if I sign it now and read it |
_o__) later?” —http://www.achewood.com/ |
More information about the Python-ideas