By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,995 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,995 IT Pros & Developers. It's quick & easy.

Automatic caching and dependency evaluation among variables?

P: n/a
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).
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.