Quick and dirty caching of function results on disk using pickle
Project description
pklcache
The name stands for pickle cache, and it is a quick and dirty way of caching function results on disk using pickle.
This can be helpful for example in some machine learning tasks, where you have to preprocess the data with many time-consuming steps, and you want to not recompute things every time you run your program.
Example
from pklcache import cache
@cache("foo_result.pkl")
def foo(*args, **kwargs):
# time consuming operations here...
return result
If you run the program
result = foo() #foo executed
And if you run it again
result = foo() #foo not executed, load result from disk
The first time foo is called its result is saved on disk on foo_cache.pkl. If then the function is called another time or the program is run again, foo is not executed, instead its return value is loaded from disk and returned.
Args
@cache(fpath, enabled=True)
fpath: is the cache file pathenabled: ifFalsethe store/load is disabled and the function is executed like if it wasn't decorated. Useful during development and debugging.
Install
pip install pklcache
If you don't want an external dependency just copy and paste the code in __init__.py
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pklcache-0.3.tar.gz.
File metadata
- Download URL: pklcache-0.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee6318fd5f73ff4bb5508a6ee6ae873450fedfb3300c4f80980d0621b1418840
|
|
| MD5 |
a3aea464b0f07486be39411a8c7ba329
|
|
| BLAKE2b-256 |
98e382045c68fe3e4fbd0906ccbdea3423785146acc93b4f3bf1040da43c23f5
|
File details
Details for the file pklcache-0.3-py3-none-any.whl.
File metadata
- Download URL: pklcache-0.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a715c997c78fe90b2ee10fca3b30e328bb927a4479d00ddbadb70ac66ff6c13b
|
|
| MD5 |
1a52f915fd2f79a91e91ae124d37c513
|
|
| BLAKE2b-256 |
e5351c94d8a702f7bb012f457452d5845802faf916af366cb1728724e2dc8003
|