Re: Trellis + expensive operations
"Sergey Schetinin" <[email protected]> Wed, 26 Nov 2008 19:38:54 +0200
| Newsgroups | gmane.comp.python.peak |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Nov 26, 2008 at 19:29, Phillip J. Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> wrote: > At 10:50 AM 11/26/2008 +0200, Sergey Schetinin wrote: >> >> I think this can be accomplished by creating a cell type that when it >> runs does not recompute itself unless there are listeners. If there >> are none it just sets some flag that indicates that it will need to >> recompute on next access and preserves its dependencies. Its get_value >> would check that flag and actually compute the value and cache it, it >> would also need to make sure that dependencies are updated at this >> point. > > I don't see how that's different from a @compute rule, except that @compute > rules don't keep track of whether their value is dirty, and so are always > recalculated "on next access" if there are no listeners. However, as soon > as that recalculation is done, if there's a listener, then it keeps track of > dependencies and is not recalculated until they change. > > I actually considered implementing @compute as you describe, but found it to > be over-complicated for the use case. I believe what Christropher wants is to access it without creating a listener, so I wasn't suggesting putting something like that into Trellis, just how he should be able to get the behavior he described.