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.11.tar.gz
(16.2 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-5.0.11.tar.gz
.
File metadata
- Download URL: outcome-utils-5.0.11.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-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ac368b8d35bc2ddabd08b6b94cd3ebfbb72f65e593a38828e9c4f20ce41db96 |
|
MD5 | 7c2b752e841aa5d7d47b08c46a876220 |
|
BLAKE2b-256 | 9a11e2f5fa293b0d40e63bb5f113447972fa97eb4c0fb86d8e8586240250e9df |
File details
Details for the file outcome_utils-5.0.11-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-5.0.11-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-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62baeee0562f6078a1035121f883e9ea698941238722524de6fc21bcc394fac8 |
|
MD5 | 27d0b9664d642a5858aedf2d1e1469a2 |
|
BLAKE2b-256 | 101d848f5f793acd100f0552637f2fffe56ba66602af29630f3272f3835fa65c |