Closed yongrenjie closed 3 years ago
Fixed by b9cbd54
I use the MD5 algorithm to generate a hash from the input code, and write/read the output from an appropriately named file.
However, it doesn't entirely work with the :context: flag.
Therefore, whenever any context preservation is done (i.e. if the context
option is enabled in this block OR if the context
dictionary is non-empty), then caching is disabled.
In all honesty the context preservation is a bad thing IMO because of the 'global state' requirement.
I'd have to look inside plot_directive for the implementation of this, but basically, I'm thinking we can hash the input code to generate a unique filename and dump the output to that file.
If the output filename already exists then instead of running the code we can just read in that file.
However, we should also make sure to enable/disable this behaviour with an option.
[Should the options like context, etc. be part of the hash as well...?]
Since performance doesn't seem to be a huge issue, I'm not hugely fussed about implementing this. But it would be a very nice addition especially for long computations.