A collection of python utils.
Project description
utils-py
A set of python utilities.
Usage
poetry add outcome-utils
Cache
To add cache to a module
from outcome.utils import cache
cache_settings = {
'<your_prefix>.expiration': 300, # Default
'<your_prefix>.backend': 'memory', # Default
}
region = cache.get_cache_region()
cache.configure_cache_region(region, settings=cache_settings, prefix='<your_prefix>')
Then add to the functions to cache:
@region.cache_on_arguments()
def func_to_cache():
...
Or for async functions:
@region.cache_on_arguments()
@cache.cache_async
async def async_func_to_cache():
...
To have the cache persist on disk, specify the path
from pathlib import Path
cache_settings = {
...
'<your_prefix>.cache_path': f'{Path.home()}/.cache/example_path/cache.pkl'',
...
}
Development
Remember to run ./pre-commit.sh
when you clone the repository.
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
outcome-utils-4.20.0.tar.gz
(17.0 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-4.20.0.tar.gz
.
File metadata
- Download URL: outcome-utils-4.20.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.6 Linux/5.4.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cb387cabca23953a696b90cd9a1d9234ff3893e4803c1d6daea4559231e5002 |
|
MD5 | 896095433d5f3f549a72264b1e50b505 |
|
BLAKE2b-256 | a6a16974cd5b8cbde60639812afcdd7a8a2f1c7d2877655b7b1a84bca6be9125 |
File details
Details for the file outcome_utils-4.20.0-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-4.20.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.6 Linux/5.4.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 562e6f2488a52c1fc19cafc54292715195aaf84d0c759d24d33f78ed6ec626f1 |
|
MD5 | 18f97c748a3302d2209771855d921080 |
|
BLAKE2b-256 | d11a9eb0550a1e719f8037f2685b9a43c260e6856055232e9065c832f6dda806 |