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-5.0.12.tar.gz
(16.2 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-5.0.12.tar.gz
.
File metadata
- Download URL: outcome-utils-5.0.12.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1043-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c82f17bf4125a9307b4b5831ab40163523d6199c3b9765ff21d6d1a71d55535 |
|
MD5 | b91c6589bbf40b4d72fb3a22bde551dd |
|
BLAKE2b-256 | 37174c4a5187f5e1ae6df72b1adab3453e644cd1ca94c0434a7c969f94eaef0f |
File details
Details for the file outcome_utils-5.0.12-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-5.0.12-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1043-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0009fae5528329b012b734bd891d150f0a5886bda40010479045cc113f353558 |
|
MD5 | 0d255914fcb8ffbcd39bab406f78e5d4 |
|
BLAKE2b-256 | d19afab509fe704518a677d525bad475bd15888a0579a0ad77c1f7628624091b |