Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33434

Re: Lazy Attribute

Subject Re: Lazy Attribute
From "Stefan H. Holek" <stefan@epy.co.at>
Date 2012-11-16 13:46 +0100
References <F1457CC9-913B-4437-A9C7-7775706DC592@epy.co.at> <DUB117-W1382A140FEE822A755FE2C691510@phx.gbl>
Newsgroups comp.lang.python
Message-ID <mailman.3748.1353069963.27098.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Lazy Attribute Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-15 15:46 -0700
  Re: Lazy Attribute Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-16 10:29 +0000
    Re: Lazy Attribute "Stefan H. Holek" <stefan@epy.co.at> - 2012-11-16 11:45 +0100
    RE: Lazy Attribute Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-16 13:46 +0300
    Re: Lazy Attribute "Stefan H. Holek" <stefan@epy.co.at> - 2012-11-16 13:46 +0100

csiph-web