- Notifications
You must be signed in to change notification settings - Fork8
brmscheiner/memorize.py
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Memorize.py is a Python decorator for caching a function's results in local storage.
In many situations, recycling the output of a function is more efficient than running the function multiple times. Atypical memoizing decorator does exactly that for as long as a program is running (the output is stored in Python variable space). Memorize.py stores the output as a .cache file in the current (or target file's) directory for reuse in future program executions. If the Python file containing the decorated function has changed since the last run, the current cache is deleted and a new cache is created (in case the behavior of the function has changed).
BEWARE: onlypure functions should be memoized!Otherwise you might encounter unexpected results.
- Does your function have any external effects? (writing to a file, printing to the console, changing a global variable...)
- Does the function depend on anything outside of the current file that may have changed (external classes, methods, functions, or data)?
Don't use this for functions whose arguments can't be dictionary keys (such as lists). I'd like to add support for this in the future.
pip install memorize.py
from memorize import Memorize@Memorizedef yourFunction(x, y, z): # do great things...About
A basic decorator for caching a function's results in local storage.
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.