Timeline for Clever caching of a recursively defined function
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 21, 2018 at 9:01 | history | tweeted | twitter.com/StackMma/status/1043062682239332352 | ||
| Sep 21, 2018 at 3:36 | vote | accept | მამუკა ჯიბლაძე | ||
| Sep 20, 2018 at 20:23 | answer | added | Szabolcs | timeline score: 7 | |
| Sep 20, 2018 at 20:10 | comment | added | Szabolcs | A final idea is that when a certain value is requested, it should be bumped to the top of the association. Consider asc = <|"a" -> 1, "b" -> 2|>, then AssociateTo[asc, "a" -> 1], which is fast but doesn't reorder keys, and AppendTo[asc, "a" -> 1], which is slower, but places the key at the end. With some small performance hit, you can bump values to the top on every hit. Thus when you prune old values, the values that are removed will be the ones that have not been requested recently. | |
| Sep 20, 2018 at 20:04 | comment | added | Szabolcs | Also this: mathematica.stackexchange.com/q/19536/12 | |
| Sep 20, 2018 at 20:02 | comment | added | Szabolcs | A long time ago I wrote a small note about how to do this. Since then, we got Association, which is better for this purpose. MaTeX uses it. Here's the function to store values in the cache. Here's how to retrieve them. MaTeX needs to retrieve multiple values at a time, you'll only need a single. Sorry, no time for a proper answer, but these should give you some ideas. | |
| Sep 20, 2018 at 19:51 | history | asked | მამუკა ჯიბლაძე | CC BY-SA 4.0 |