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.12.6.tar.gz
(13.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file outcome-utils-4.12.6.tar.gz.
File metadata
- Download URL: outcome-utils-4.12.6.tar.gz
- Upload date:
- Size: 13.6 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 |
248ffd2747566eeb34b5e575a919963046efe6f21643542f8b262bc6f18ce7f6
|
|
| MD5 |
82ea23fc81d06488e43368cd3c7845cc
|
|
| BLAKE2b-256 |
89b3b8004135959d867b1837b90424fe434dd1a0e31e78119a938dd400772eaf
|
File details
Details for the file outcome_utils-4.12.6-py3-none-any.whl.
File metadata
- Download URL: outcome_utils-4.12.6-py3-none-any.whl
- Upload date:
- Size: 16.4 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 |
c047dbde3fb03aed059a3ba99f630fe8ff7c612fcca4073a94f922701ee3f7ad
|
|
| MD5 |
c9bcfc309c8f6161e52d8b41dbbbed6e
|
|
| BLAKE2b-256 |
b9568e080b58cd2deedd40ac54a67cd584713accc485aca382c1b2035ef18dc8
|