No project description provided
Project description
Cachephant
Cachephant is a small python library which caches function output to disk to avoid unnecessary recomputation. It's aimed for use in Jupyter notebooks.
Problem
There's already joblib.Memory
and diskcache.memoize
. However, they didn't provide the behavior I desired:
uses cache if... | joblib | diskcache | cachephant |
---|---|---|---|
Jupyter kernel restarts | n | y | y |
arguments leading to same "resolved" arguments change | n | n ! | y |
some unrelated code changes | n | y | y |
some related code changes | n | y | y (n would be ideal but difficult) |
function code changes | n | y ! | n |
function signature changes | raises error | y ! | n |
How to use
import cachephant
cache = cachephant.get_default_cache("/path/to/dir")
@cache
def slow_function():
time.sleep(10)
return 3
You can also instantiate cachephant.Cache()
and easily pass custom database-, file-, hash-, and evictor-classes.
Non-goals
This library is not meant for high frequency use cases (think hundreds of cache reads/writes per second) and you'll likely see performance issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cachephant-0.2.0.tar.gz
(6.3 kB
view hashes)
Built Distribution
Close
Hashes for cachephant-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7297d0ce45364322c34b04a9685aebe8956b50a78c5e451afb9a46f54fa0e4c4 |
|
MD5 | b78c8e94a7dac146759f6ae3c807ec15 |
|
BLAKE2b-256 | c63d8d0993f4b374b35bbcb388dd30a9485fff5a532edf9bd720edd33fe9ccf7 |