Pythod Cached Decorator providing caching for functions
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Cached.py
LICENSE
readme.md

readme.md

Python Cached Decorator

MIT license

Provides caching for functions

  • Suitable for time consuming computations
  • How does it work:
    • First run = run
    • Second run = load result
  • Stores result in pickle
  • Checks if function args matches
  • Always use newest result

Example

from Cached import Cached

@Cached()
# possible params: Cached(force_run=False, output_path="cached_data", name="")
def func(arg):
    return arg

print fun(5)

Options

All options are optional

  • force_run [True/False] Do not use cached result
  • output_path [String] default=cached_data in script path, /tmp is a good idea
  • name [String] default=function name, force function name - used for store and load

Development

Feel free to contribute.

Copyright and License

© 2015 Vít Listík, Michal Bukovský

Released under MIT licence