Skip to main content

A collection of production-ready Python decorators and generators

Project description

pydecorx

A collection of production-ready Python decorators and generators

pydecorx provides a set of modular, reusable utilities to simplify common Python patterns like logging, retrying, caching, type validation, and file/data stream processing.


📦 Features

✅ Decorators

  • log_execution – Log function calls, arguments, return values, and execution time
  • retry_on_exception – Retry failed function calls with configurable delay
  • cache_result – In-memory caching with TTL support
  • time_execution – Log how long a function takes to run
  • once – Ensure a function runs only once
  • memoize – Simple caching without TTL
  • benchmark – Warn if a function exceeds an execution threshold
  • deprecated – Emit deprecation warnings
  • suppress_exceptions – Gracefully handle and suppress specified exceptions
  • rate_limiter – Limit how often a function can be called
  • validate_types – Enforce type hints at runtime
  • async_safe – Make sync functions awaitable in async code

🔁 Generators

  • fibonacci – Infinite Fibonacci number stream
  • file_chunker – Read large files in fixed-size chunks
  • tail_reader – Mimics tail -f for real-time file streaming
  • sliding_window – Yields fixed-size windows over iterables
  • paginated_api_reader – Read items from paginated APIs
  • batched_iterable – Yield batches of items from iterables
  • directory_watcher – Yield new filenames as they appear in a directory
  • csv_row_reader – Stream rows from large CSV files

🔧 Installation

pip install pydecorx

Or from source (editable):

git clone https://github.com/manas-shinde/python-decorators-generators.git
cd python-decorators-generators
pip install -e .

🚀 Usage Example

from decorators.retry_decorator import retry_on_exception

@retry_on_exception(retries=3, delay=1)
def fetch_data():
    # some flaky operation
    pass
from generators.batched_iterable import batched_iterable

for batch in batched_iterable(range(10), batch_size=3):
    print(batch)

🧪 Testing

Install test dependencies and run tests:

pip install -r requirements.txt
pytest tests/

📚 License

MIT License

🔗 Project Links

Source: GitHub Repository

PyPI: https://pypi.org/project/pydecorx

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydecorx-1.0.1.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydecorx-1.0.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file pydecorx-1.0.1.tar.gz.

File metadata

  • Download URL: pydecorx-1.0.1.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pydecorx-1.0.1.tar.gz
Algorithm Hash digest
SHA256 cde1344ab07edd9ced65a2d730d0b64225be333c7e1e3664392879995e2339d9
MD5 3b4b55564199bb77cfae9752ede0c825
BLAKE2b-256 3a2df0785e8cd1f303dde54d6c0b0fabe7db28555d234afa3eb84b482b1ee8e5

See more details on using hashes here.

File details

Details for the file pydecorx-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pydecorx-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pydecorx-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 954a4bfc0b8773866d80c2c45dc2a001dd1c9b092233b51f650ffbf462b858c0
MD5 4fe3c53399d4695fff69fa1db835ebbb
BLAKE2b-256 6f2bf61af4c524167ed5b84d4bb4c13a344650880092c0f2403f877bee5750f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page