Ibhax - The Ultimate Decorator Toolkit
ibhax is a powerful and versatile Python library that provides 100 production-grade decorators to enhance your development workflow. It includes decorators for logging, debugging, caching, performance monitoring, security, error handling, and much more.
Features
✅ 100+ Ready-to-Use Decorators
✅ Production-Grade Implementation
✅ Performance & Debugging Tools
✅ Error Handling & Security Enhancements
✅ Logging & Monitoring Support
✅ Simple and Flexible API
Installation
Install ibhax using pip:
pip install ibhax
Quickstart
Import DecoratorFactory and start using decorators right away:
from ibhax.decorators import DecoratorFactory
factory = DecoratorFactory()
@factory.deprecated("Use `new_function()` instead.")
def old_function():
print("This function is deprecated.")
old_function()
Example Output:
============================================================
DEPRECATION NOTICE
Function : old_function
Location : example.py:8
Reason : Use `new_function()` instead.
Recommendation : Please update your code accordingly.
============================================================
This function is deprecated.
Available Decorators (Highlights)
The DecoratorFactory class provides 100 powerful decorators. Here are a few:
| Decorator Name | Description |
|---|---|
@factory.deprecated |
Marks a function as deprecated with a custom warning. |
@factory.log_execution_time |
Logs the execution time of a function. |
@factory.retry |
Retries a function multiple times if it fails. |
@factory.suppress_errors |
Suppresses and logs exceptions instead of breaking the program. |
@factory.cache_results |
Caches function results to improve performance. |
@factory.debug |
Logs function calls and arguments for debugging. |
@factory.thread_safe |
Ensures a function is thread-safe. |
@factory.rate_limit |
Limits the rate at which a function can be called. |
@factory.trace |
Traces execution step-by-step for debugging. |
@factory.timeout |
Sets a time limit on function execution. |
Usage Examples
1. Logging Execution Time
@factory.log_execution_time
def slow_function():
import time
time.sleep(2)
print("Finished")
slow_function()
Output:
Execution time of slow_function: 2.0000 seconds
Finished
2. Retrying a Function on Failure
@factory.retry(attempts=3, delay=1)
def unstable_function():
import random
if random.random() < 0.7:
raise ValueError("Random failure!")
print("Success!")
unstable_function()
3. Suppressing Errors
@factory.suppress_errors(default="Error occurred!")
def risky_function():
raise ValueError("Oops!")
print(risky_function()) # Output: Error occurred!
4. Debugging Function Calls
@factory.debug
def add(a, b):
return a + b
add(2, 3)
Output:
DEBUG: add called with args: (2, 3), kwargs: {}
DEBUG: add returned 5
5. Rate Limiting Function Calls
@factory.rate_limit(calls=2, period=5)
def limited_function():
print("Executed")
limited_function()
limited_function()
limited_function() # This call may be blocked if made too soon.
6. Enforcing Thread Safety
@factory.thread_safe
def safe_function():
print("Thread-safe function running.")
7. Tracing Function Execution
@factory.trace
def traced_function():
x = 5
y = x * 2
return y
traced_function()
Listing All Decorators
To see all available decorators with descriptions:
factory.list_decorators()
Contributing
We welcome contributions! Feel free to:
- Report issues
- Request new decorators
- Submit pull requests
Clone the repository and install the package in development mode:
git clone https://github.com/ibhax/decorator_factory.git
cd decorator_factory
pip install -e .
License
ibhax is licensed under the MIT License.
Links
Metadata
Release files for ibhax 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ibhax-1.0.0.tar.gz | 17.0 kB | Without provenance | Details for ibhax-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ibhax-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for ibhax-1.0.0-py3-none-any.whl |
Total release size: 32.4 kB
Release files / ibhax-1.0.0.tar.gz
| Download URL | ibhax-1.0.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
193c932115e3b80dce55f9033f849565302d4f12e7b7e5c7f7eec15955985f80
|
|
BLAKE2b-256 checksum How to use checksums |
a225f6e5007e58e431b9460b9439db8f47c0c628cc99890797eacf99c65e3178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / ibhax-1.0.0-py3-none-any.whl
| Download URL | ibhax-1.0.0-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b69bcd20cfa174c976a74d9d655747ecb00322434b1c8a28beaf91b811d037db
|
|
BLAKE2b-256 checksum How to use checksums |
b3559c986727ce1a7e3c5f867d1e63177c1d87f2aa872e385f42df60a502290a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for ibhax 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.