Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Lazy Attribute (http://www.velocityreviews.com/forums/t954560-re-lazy-attribute.html)

Stefan H. Holek 11-16-2012 12:46 PM

Re: Lazy Attribute
 
On 16.11.2012, at 11:54, Andriy Kornatskyy wrote:

>> Subject: Re: Lazy Attribute
>> From: stefan@epy.co.at
>> Date: Fri, 16 Nov 2012 11:45:32 +0100
>> To: python-list@python.org
>>
>> On 16.11.2012, at 11:29, Steven D'Aprano wrote:
>>
>>> I'm very vaguely leaning towards this as the least-worst solution to
>>> invalidating the cached value:
>>>
>>> refresh(obj, 'attr') # pass the instance and the name

>>
>> This it exactly how lazy handles invalidation. http://lazy.readthedocs.org/en/latest/

>
> @property is a solution to evaluate something that is dynamic. @attribute is good for immutable objects. Even if we assume refresh is a good idea... how I would know when it is valid to `refresh`? What is criteria?
>
> Andriy


I had to implement invalidation anyway in order to write tests. I decided to expose the mechanism to keep users from having to invent their own SHOULD the need arise. I was not advocating invalidation in any way with my reply. All I wanted was to confirm the "least bad" solution. ;-)

Stefan

--
Stefan H. Holek
stefan@epy.co.at



All times are GMT. The time now is 11:03 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57