@@ -4,7 +4,7 @@ A curated collection of production-ready, reusable Python decorators and generat
44
55This package includes:
66
7- - ✅ Common decorators like logging, retrying, caching, and timing
7+ - ✅ Common decorators like logging, retrying, caching, timing, and more
88- ✅ Generators for streaming data, infinite sequences, and efficient file processing
99- ✅ Unit tests and GitHub Actions CI
1010- ✅ Editable install via ` pyproject.toml ` for clean imports
@@ -39,47 +39,71 @@ time_execution Logs how long a function takes to run
3939``` bash
4040python-decorators-generators/
4141├── decorators/
42- │ ├── logging* decorator.py
43- │ ├── retry_decorator.py
44- │ ├── cache_decorator.py
45- │ └── time_decorator.py
42+ │ ├── logging_decorator.py
43+ │ ├── retry_decorator.py
44+ │ ├── cache_decorator.py
45+ │ ├── time_decorator.py
46+ │ ├── once.py
47+ │ ├── memoize.py
48+ │ ├── benchmark.py
49+ │ ├── deprecated.py
50+ │ └── async_safe.py
4651│
4752├── generators/
48- │ ├── fibonacci.py
49- │ ├── file_chunker.py
50- │ └── tail_reader.py
53+ │ ├── fibonacci.py
54+ │ ├── file_chunker.py
55+ │ ├── tail_reader.py
56+ │ ├── sliding_window.py
57+ │ ├── paginated_api_reader.py
58+ │ ├── batched_iterable.py
59+ │ └── directory_watcher.py
60+ │ └── csv_row_reader.py
5161│
5262├── examples/
53- │ └── demo * < name> .py
63+ │ └── demo_ < name> .py
5464│
5565├── tests/
56- │ └── test \_ < name> .py
66+ │ └── test_ < name> .py
5767│
5868├── pyproject.toml
5969├── requirements.txt
6070└── README.md
71+
6172```
6273
6374---
6475
6576### ✅ Decorators Included
6677
67- | Decorator | Module | Description |
68- | -------------------- | ------------------------------ | ------------------------------------------------------------------------- |
69- | ` log_execution ` | ` decorators.logging_decorator ` | Logs function calls, arguments, return values, execution time, and errors |
70- | ` retry_on_exception ` | ` decorators.retry_decorator ` | Retries a function on failure, with customizable retry count and delay |
71- | ` cache_result ` | ` decorators.cache_decorator ` | In-memory caching with configurable TTL |
72- | ` time_execution ` | ` decorators.time_decorator ` | Logs how long a function takes to run |
78+ | Decorator | Module | Description |
79+ | --------------------- | -------------------------------- | ------------------------------------------------------------------------- |
80+ | ` log_execution ` | ` decorators.logging_decorator ` | Logs function calls, arguments, return values, execution time, and errors |
81+ | ` retry_on_exception ` | ` decorators.retry_decorator ` | Retries a function on failure, with customizable retry count and delay |
82+ | ` cache_result ` | ` decorators.cache_decorator ` | In-memory caching with configurable TTL |
83+ | ` time_execution ` | ` decorators.time_decorator ` | Logs how long a function takes to run |
84+ | ` once ` | ` decorators.once ` | Ensures a function runs only once |
85+ | ` memoize ` | ` decorators.memoize ` | Simple non-TTL in-memory caching |
86+ | ` benchmark ` | ` decorators.benchmark ` | Logs function execution time, warns if it exceeds a threshold |
87+ | ` deprecated ` | ` decorators.deprecated ` | Emits a warning when a deprecated function is called |
88+ | ` suppress_exceptions ` | ` decorators.suppress_exceptions ` | Suppresses specified exceptions and optionally logs them |
89+ | ` rate_limiter ` | ` decorators.rate_limiter ` | Limits how frequently a function can be called |
90+ | ` validate_types ` | ` decorators.validate_types ` | Runtime type checking for arguments and return values |
91+ | ` async_safe ` | ` decorators.async_safe ` | Makes sync functions awaitable in async contexts |
7392
7493---
7594
7695### 🔁 Generators Included
7796
78- | Generator | Module | Description |
79- | ---------------- | ------------------------- | ------------------------------------------------------------- |
80- | ` fibonacci() ` | ` generators.fibonacci ` | Infinite lazy sequence of Fibonacci numbers |
81- | ` file_chunker() ` | ` generators.file_chunker ` | Reads large files in fixed-size chunks using lazy loading |
82- | ` tail_reader() ` | ` generators.tail_reader ` | Mimics ` tail -f ` to stream new lines from a file in real-time |
97+ | Generator | Module | Description |
98+ | ------------------------ | ---------------------------------- | ------------------------------------------------------------- |
99+ | ` fibonacci() ` | ` generators.fibonacci ` | Infinite lazy sequence of Fibonacci numbers |
100+ | ` file_chunker() ` | ` generators.file_chunker ` | Reads large files in fixed-size chunks using lazy loading |
101+ | ` tail_reader() ` | ` generators.tail_reader ` | Mimics ` tail -f ` to stream new lines from a file in real-time |
102+ | ` sliding_window() ` | ` generators.sliding_window ` | Yields a sliding window over an iterable |
103+ | ` paginated_api_reader() ` | ` generators.paginated_api_reader ` | Yields results from paginated API endpoints |
104+ | ` batched_iterable() ` | ` generators.batched_iterable ` | Yields fixed-size batches from any iterable |
105+ | ` directory_watcher() ` | ` generators.directory_watcher ` | Yields filenames as new files appear in a directory |
106+ | ` csv_row_reader() ` | ` generators.csv_row_reader Streams ` | rows from large CSVs as dictionaries |
83107
84108---
85109
0 commit comments