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.23.1.tar.gz
(17.7 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-4.23.1.tar.gz
.
File metadata
- Download URL: outcome-utils-4.23.1.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20d90cd166afd1450494c3b1fc9088adbfdf62e5d7f67ca25d9150d0e4138c8b |
|
MD5 | 6f42ac3f907f2e8c272ea42cbcf02630 |
|
BLAKE2b-256 | e7d4625387281ccdcb10d29f068f1e99991a3334cad0a92baedc172698346ce7 |
File details
Details for the file outcome_utils-4.23.1-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-4.23.1-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc1c0ddb765271bde756ce5c4fdda865c2f2f84c89e6c809d01f002163d302a3 |
|
MD5 | 030e70db13ba50b551879d5a521bc933 |
|
BLAKE2b-256 | 99e26bcb9293bd8988da5b76abfe148959c818e18c50c3c6b73c9a3f6e93cf44 |