A lightweight and modular Python decorator library
Project description
pydecora ๐งฉ
A lightweight and modular Python decorator library that helps you write cleaner and more expressive code.
๐ Features
- ๐ง
@cache: Simple in-memory caching with optional TTL and size limit - ๐
@retry: Automatically retry failed operations with exponential backoff - ๐
@suppress: Suppress exceptions and optionally log them - โฑ๏ธ
@timeit: Time execution of functions - ๐งช
@validate_args: Enforce argument types using runtime validation - ๐ง
@singleton: Ensure a class is instantiated only once (classic singleton pattern)
๐ฆ Installation
pip install pydecora
๐งโ๐ป Usage
from pydecora import cache, retry
@cache(ttl=60)
def slow_func(x):
return x * x
@retry(times=3, delay=1)
def flaky_api_call():
...
@singleton
class Config:
def __init__(self):
self.value = 42
๐ Project Structure
pydecora/
โโโ pydecora/
โ โโโ init.py
โ โโโ decorators/
โ โโโ cache.py
โ โโโ retry.py
โ โโโ singleton.py
โ โโโ suppress.py
โ โโโ timeit.py
โ โโโ validate_args.py
โโโ tests/
โ โโโ test_cache.py
โ โโโ test_retry.py
โ โโโ test_singleton.py
โ โโโ test_suppress.py
โ โโโ test_timeit.py
โ โโโ test_validate_args.py
โโโ README.md
โโโ LICENSE
โโโ setup.py
โโโ pyproject.toml
๐งช Running Tests
pytest pydecora/tests
๐ค Contributing
Pull requests and ideas welcome! Please open an issue or fork and PR.
๐ License
MIT โ see LICENSE
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
pydecora-1.1.3.tar.gz
(10.3 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
pydecora-1.1.3-py3-none-any.whl
(12.6 kB
view details)
File details
Details for the file pydecora-1.1.3.tar.gz.
File metadata
- Download URL: pydecora-1.1.3.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44b15c8dce32585baa6afa0c654dcfd807beea254a0d23f10a30bf57005f9b00
|
|
| MD5 |
89dc8264a956341901543f56a3fdc529
|
|
| BLAKE2b-256 |
e7490e129d134ca6ada46674478c31bfde849d79b7d212c5f2a9816ba37f0018
|
File details
Details for the file pydecora-1.1.3-py3-none-any.whl.
File metadata
- Download URL: pydecora-1.1.3-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03d3ee8799daf463f6306541ced8487da4f537b193b4bcdee074ff1772270b40
|
|
| MD5 |
219ffdb903a318d5c2ce908f337ff66d
|
|
| BLAKE2b-256 |
07f951b4e0d63d2052b85dfddabd8241f9064537841b99c3ea41db5e4a5b5af0
|