Skip to content

ersincine/persistent-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

persistent-cache

@persistent_cache() is a persistent @functools.cache.

Exemplary use cases include the following:

Pause and continue

Let's say the loop below takes a day to finish. I can terminate (pause) the program anytime I need. Then I can run it again (continue).

for a in range(50):
    for b in range(50):
        slow_func_that_writes_to_files(a, b)

Batch processing

Maybe I want to visualize the results of calc. I can perform these computations during my sleep. When I start working, I can quickly run:

for a in range(1000):
    x = calc(a)
    display(x)

Interactive experiments

In an interactive shell (or a Jupyter Notebook), I can do many experiments calling slow functions. Inputs will sometimes repeat.

result = match_images("img-3.png", "img-7.png")  # Maybe I already did this before. 

About

Make your script remember every result forever.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages