Re: Lazy Attribute

Discussion in 'Python' started by Stefan H. Holek, Nov 16, 2012.

  1. On 16.11.2012, at 11:54, Andriy Kornatskyy wrote:

    >> Subject: Re: Lazy Attribute
    >> From:
    >> Date: Fri, 16 Nov 2012 11:45:32 +0100
    >> To:
    >>
    >> 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 H. Holek, Nov 16, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Pu
    Replies:
    3
    Views:
    674
    Steven D'Aprano
    Jan 16, 2009
  2. Boris Borcic
    Replies:
    0
    Views:
    550
    Boris Borcic
    Jan 16, 2009
  3. Boris Borcic
    Replies:
    0
    Views:
    547
    Boris Borcic
    Jan 16, 2009
  4. Ian Kelly

    Re: Lazy Attribute

    Ian Kelly, Nov 15, 2012, in forum: Python
    Replies:
    0
    Views:
    175
    Ian Kelly
    Nov 15, 2012
  5. Andriy Kornatskyy

    RE: Lazy Attribute

    Andriy Kornatskyy, Nov 16, 2012, in forum: Python
    Replies:
    3
    Views:
    155
    Rouslan Korneychuk
    Nov 16, 2012
Loading...

Share This Page