Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Automatic caching and dependency evaluation among variables?

Reply
Thread Tools

Automatic caching and dependency evaluation among variables?

 
 
Ori Berger
Guest
Posts: n/a
 
      04-29-2004
I *think* I saw a post some time ago enabling "spreadsheet" like
computations, that allows something along the lines of:

>>> vars.a = 10
>>> vars.b = dependency("vars.a * 20")
>>> print vars.b

200
>>> vars.a = 50
>>> print vars.b

1000

(Not sure what the actual syntax definitions were)
And vars.b was only re-computed if vars.a was changed -
otherwise a cached value was returned.

I can write this myself, but the solution I'm thinking of is
inelegant, and I remember the solution was extremely short and
elegant; I can't find anything in the google archives, though.

Anyone perhaps have a link or other helpful info?

(My idea of how to do it: make vars a special dict that logs
every __get__, and that can have callbacks when something is
__set__. the dependency() code would evaluate the expression,
see what __get__s were logged, and attach the same expression to
be reevaluated when any of those were __set__.

It becomes complicated, though, if I wish to track changes to
vars.subvar1.subvar2.subvar3 as well, though).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning a const reference brokes dependency among header files? Kermit Mei C++ 1 09-23-2008 12:30 AM
Partial caching (a UserControl) with file dependency Rolf Welskes ASP .Net 6 10-24-2006 12:32 PM
[EVALUATION] - E03 - jamLang Evaluation Case Applied to Python Ilias Lazaridis Python 2 04-24-2005 05:29 PM
[EVALUATION] - E04 - jamPersist Evaluation Case Applied to Ruby Ilias Lazaridis Ruby 18 04-09-2005 04:45 PM
[EVALUATION] - E03 - jamLang Evaluation Case Applied to Ruby Ilias Lazaridis Ruby 74 04-04-2005 05:29 PM



Advertisments