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.7.tar.gz
(16.2 kB
view details)
Built Distribution
File details
Details for the file outcome-utils-5.0.7.tar.gz
.
File metadata
- Download URL: outcome-utils-5.0.7.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 | 92cea6ad6a30d2ae71815ed115de3cf08eb68bf9d265e1076ae86f534a26b533 |
|
MD5 | d6f650347fa99f933d3d37244e827cc8 |
|
BLAKE2b-256 | 4c81d2cafb57f609ab66b8c61e1cda1e652c8b930fe8d6615bdcbc5276b0e788 |
File details
Details for the file outcome_utils-5.0.7-py3-none-any.whl
.
File metadata
- Download URL: outcome_utils-5.0.7-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 | a0b75a269f4e3638d57f65663b090abf8d6ae23f28e162a2c24061768f2038f2 |
|
MD5 | 0ed88bc5234e96680bfdf5e9655fcfe4 |
|
BLAKE2b-256 | 27045fb32312e78a1192e855ed5490705fb84ff70f5fc192ad483ae397f1adf6 |