Python Library for decorators
Decorify is a lightweight Python library without any dependencies that offers a collection of simple, reusable decorators to enhance your functions. These decorators cover common use cases like logging, timing, retrying, and more.
Install Decorators via pip:
pip install decorify | Decorator | Main functionality |
|---|---|
| timeit | Measures the time of the function |
| timeout | Terminates the function after it runs for too long |
| mute | Disables stdout for duration of decorated function |
| validate_typehints | Ensures that typehints are followed, raising error if not |
| retry | If exception is raised function is retried up to predefined amount of times |
| rate_limiter | Limits number of function calls such that there are no function calls within set amount of seconds |
| interval_rate_limiter | Splits time into intervals, and limits the number of function calls within each interval |
| default_value | Set default value for function if exception is raised |
| grid_search | Allow user to perform grid search on each iteration of function call |
| redirect | Enables user to redirect function stdout / stderr |
| crawler | Looks for function calls structure and displays it as a tree or nested lists |
- loop: On each call, function is performed n times and all outputs are returned in a list
- average: Function return mean value of n runs
- plot_multiple: Creates a plot of a function's return values
- plot_single: Creates a plot of a function's return
Contributions are welcome! Please submit a pull request or open an issue to add new decorators or suggest improvements.
This project is licensed under the Apache v2.0 License.