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.18.0.tar.gz
(15.8 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-4.18.0.tar.gz
.
File metadata
- Download URL: outcome-utils-4.18.0.tar.gz
- Upload date:
- Size: 15.8 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 | f6dfbf540f13d32507e9041537a371af21fb8399be8d08c718a86d6f72c94ce9 |
|
MD5 | 82d27d722cfecb9dfa902211b45cadd4 |
|
BLAKE2b-256 | 8efc2d6695ea73771acd7bfb50f3033b6a8cb15bc81ed52248a63e7d7b4e1576 |
File details
Details for the file outcome_utils-4.18.0-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-4.18.0-py3-none-any.whl
- Upload date:
- Size: 19.0 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 | da113f0f12da467240d67d2737c5e7b357cd2752cef85d61081bb6870d3b00ff |
|
MD5 | 970c219187c819e553143e9b5bdf7438 |
|
BLAKE2b-256 | 6e06c1cc9a8bf3bfb6dd79cda02d1fec61729d5782578ad4ce85f86f4e6d0875 |