
April 30, 2009
5:57 a.m.
On Thu, 30 Apr 2009 08:33:27 am Benjamin Peterson wrote:
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.
-1 on an extra parameter to property. +1 on a cache decorator. It is clear and simple enough to write something like: @property @cache # or "once" if you prefer the Eiffel name def value(self): pass Such a decorator could then be used on any appropriate function, not just for properties. -- Steven D'Aprano