-
-
Notifications
You must be signed in to change notification settings - Fork 33
Caching data between runs
Almenon edited this page Feb 9, 2020
·
8 revisions
Sometimes you might execute a lengthy query that you do not want to run again. Never fear, you can cache the result so it is saved inbetween runs! You have two options:
-
use #$save (see readme)
-
Using "arepl_store"
arepl_store is a variable that will hold data between runs.
If you assign a value to it and then comment that line out you can still reference that variable.
from time import sleep
def longLastingFunction():
sleep(5)
x = longLastingFunction() # ugg takes forever each run
from time import sleep
def longLastingFunction():
sleep(5)
arepl_store = longLastingFunction() # Instead I'll put it in my store
from time import sleep
def longLastingFunction():
sleep(5)
# arepl_store = longLastingFunction() # comment this out - we don't want to call longLastingFunction twice!
print(arepl_store) # now I can get the function result without actually running the function!