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.6.tar.gz
(16.2 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-5.0.6.tar.gz
.
File metadata
- Download URL: outcome-utils-5.0.6.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 | 5dd2b43caf880c364393f8e0b57bb1a3457b7dc4449ff5e097bf0bb28cd6d34b |
|
MD5 | 08b8f10f285c712e7e06da406349db0c |
|
BLAKE2b-256 | 433e231babf201d0b6c2f3646e9897c852674ba6e14b20e2e047a1def9e93dee |
File details
Details for the file outcome_utils-5.0.6-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-5.0.6-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-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d57374c640068d6de12e778d5f33f11bdcf17ce21869f0355be71d650fb98223 |
|
MD5 | cc035f708bb4f6eb5c12cdd16194db94 |
|
BLAKE2b-256 | bae4f08959492a73e3008769f2634e53606d4845d97e3d40dd94b06584933864 |