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.9.tar.gz
(16.2 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-5.0.9.tar.gz
.
File metadata
- Download URL: outcome-utils-5.0.9.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-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b08851b1c2f8a52dbc0c8d25abeffb21217902fc839b980c151187158c6f3866 |
|
MD5 | b881b3b4c9354b9b39d9c1ca7377466f |
|
BLAKE2b-256 | 627f2e87d0883bb2987cc0836a6b52c3e8ea31df90ba1379249b044bffcaa1b4 |
File details
Details for the file outcome_utils-5.0.9-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-5.0.9-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 579f04280855b429b4a571ad227867a5c22dc9cb8cb79b035acec20e4265801d |
|
MD5 | 8c482976de0e221c8079403622976687 |
|
BLAKE2b-256 | b71ff1e4310b4eeb643b82a4f675759eb381284da9556c39847a5ae5a78b2836 |