Cacha
The simplest Python cache for Data Scientist:
- cache on disk, use between runs,
- use at function call, not definition.
Example
If you don't want to wait for a given compute() function to complete
each time you run the script, you can cache it:
import cacha
result = compute(data) # regular usage, slow
result = cacha.cache(compute, (data, )) # usage with cache
The cached data is stored in $HOME/.cacha/. Each time you run the
function with identical input arguments, the output data will be loaded,
instead of being computed.
It can be easily used with popular data structures like pandas.DataFrame or
numpy.array. In case of complicated python objects that can't be easily
hashed, you can use an additional key parameter that forces saving the cache
based on the key value.
import cacha
result = cacha.cache(compute, (data, ), key="compute-v3")
FAQ
How is it different other caching packages?
In contrary to many other tools, cacha:
- is used at the function call, not definition. Many packages implement
the
@cachedecorator that has to be used before definition of a function that is not easy enough to use. - it stores the cache on disk which means you can use cache between runs. This is convenient in data science work.
How can I clear the cache?
Just delete the $HOME/.cacha/ directory. You can also call cacha.clean()
which has the same effect.
Why does it require the pandas, numpy and other libraries?
To properly cache the objects from specific packages, it is necessary to have access to the functions they provide in that regard.
The main goal of cache is not to be lightweight but to provide the best developer experience.
However most of the required packages are usually used in Machine Learning projects anyway.
Metadata
Release files for cacha 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cacha-1.0.0.tar.gz | 12.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cacha-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.1 kB
Release files / cacha-1.0.0.tar.gz
| Download URL | cacha-1.0.0.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d4cdc804c2566023d1d11e6c747635362372b3e72a57db540df5ca75a138da4
|
|
BLAKE2b-256 checksum How to use checksums |
03d6f8cd4041cf394d932bcdacca0c1eb7a35008f97fe8eba8cd29dc04b46699
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.13 Darwin/21.5.0
|
Release files / cacha-1.0.0-py3-none-any.whl
| Download URL | cacha-1.0.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
858da1f27c006f5c374d96b7df2128c847333d38eaf4994f9a29decdd2bdd180
|
|
BLAKE2b-256 checksum How to use checksums |
bad9803239d87e4359f44dba5a9c3fac4704bc46a723089d3cc1127824271c44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.13 Darwin/21.5.0
|