PyCachera
A powerful python decorator to cache functions
Installation
In command line:
pip install pycachera
Usage
Import the pycachera as:
from pycachera import cache
For caching a function
@cache()
def sum(a,b):
return a+b
For caching a class attributes.
class Math:
def __init__(self):
pass
@cache()
def sum(a,b):
return a + b
For caching to a specific directory.
@cache(cachefolder='/home/user/scratch')
def sum(a,b):
return a+b
For caching with a specific key
@cache(cachekey='This a custom cache')
def sum(a,b):
return a+b
For printing the info
@cache(verbose=True)
def sum(a,b):
return a+b
While debugging your script if you want to ignore the cached values you can recache
@cache(recache=True)
def sum(a,b):
return a+b
When you use cache with a class attribute, and if you want to consider some attributes of that class for caching,
class Math:
def __init__(self,c):
self.c = c
@cache(extrarg=['c'])
def sum(a,b):
return a + b
To cache a class property,
class math:
def __init__(self,a,b):
self.a = a
self.b = b
@property
@cache(extrarg=['a','b'],verbose=True)
def add(self):
return self.a + self.b
When using mpi4py.MPI,
@cache(with_mpi=True)
def sum(a,b):
return a+b
API
visit pycachera.readthedocs.io
Metadata
Release files for pycachera 4.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pycachera-4.5.1.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycachera-4.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.7 kB
Release files / pycachera-4.5.1.tar.gz
| Download URL | pycachera-4.5.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66901d57d2129ed2e16ba1f59261eeb72efe86fbddbe21c7b65491b17504e9f6
|
|
BLAKE2b-256 checksum How to use checksums |
3c19dd80801d407514bdb7e3022ed2a65207fa7cc0cfdfb1470389f0ff3b63ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / pycachera-4.5.1-py3-none-any.whl
| Download URL | pycachera-4.5.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23e6df5c8e35bc6fa542f6a5e1b0ab53b30dc46077d0f28d389ecbccc9e9cb13
|
|
BLAKE2b-256 checksum How to use checksums |
bed2d284c9c1efa9f97f0d94cea318bee2bdf9cbb6e224e7ec5cc44c1b164326
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|