Re: Trellis + expensive operations
"Phillip J. Eby" <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> Wed, 26 Nov 2008 12:29:33 -0500
| Newsgroups | gmane.comp.python.peak |
|---|---|
| Message-ID | <[email protected]> |
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.