CachedCalls.jl

Cache function calls to disk.
Author mzgubic
Popularity
0 Stars
Updated Last
3 Months Ago
Started In
February 2021

CachedCalls

Build Status Code Style: Blue ColPrac: Contributor's Guide on Collaborative Practices for Community Packages

Functions that take a long time to run can slow down experimentation and code development. Instead of running the same function with the same inputs multiple times, the result can be cached to disk and fetched when the function is run with the same arguments again. A simple macro provides this functionality:

using CachedCalls

variable = @cached_call f(args; kwargs)

It works by hashing the macro name, values of arguments, and names and values of keyword arguments.

Gotchas

A few things to consider before using the macro:

  • Is f accessing global variables?

The second time the macro is used the returned result may be unexpected (if the global variable has changed)

  • Is f mutating its inputs or global variables?

The second time the macro is used the inputs/globals will not be mutated.

  • The inputs to the macro are considered the same if their hashes are the same.

Notably, hash(1) == hash(1.0), and similarly for DataFrames that differ only by column names. Additionally, function arguments are differentiated by name only.

Used By Packages

No packages found.