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.16.1.tar.gz
(15.5 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-4.16.1.tar.gz
.
File metadata
- Download URL: outcome-utils-4.16.1.tar.gz
- Upload date:
- Size: 15.5 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 | ea9b42d64165dcbf71cc5898d6e66001144ebef11131883d0e9d4e2935337eca |
|
MD5 | 7afbc1ab4ef31ba3f1fa2dd9f4f2430e |
|
BLAKE2b-256 | a85abac8851c87595b28a0c2ed1c2ad15fc8f24f6135c31cd60f89c408f712be |
File details
Details for the file outcome_utils-4.16.1-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-4.16.1-py3-none-any.whl
- Upload date:
- Size: 18.6 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 | 2b626eeac09f2b92b54a6633e16f5e7a9abd601b3e36e84665343a3b8e0d90aa |
|
MD5 | 2602fc77b3cea4b3587d6b47041c1bb4 |
|
BLAKE2b-256 | 1e3eda8f2307a68cecc792be6c000a715b16c3ecc38ca53a4973a2afb13cf163 |