You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Zachary Smith edited this page Aug 7, 2023
·
4 revisions
python-web-io works by re-evaluating the target script after each user interaction, to progress the script to the next input(), etc.
This means expensive functions may be called more than once per session.
To reduce latency, a cache decorator is made available through the python_web_io module.
The @cache_to_file() decorator accepts a string argument: file_path, which indicates where the cache (a .pkl file) should be stored.
importpython_web_ioasio@io.cache_to_file('cache.pickle')defexpensive_function(arg):
# Calculate the result herereturnresult