Decorators
debug(func)
Decorator to print the function signature and return value.
It prints the function name, its arguments, and its return value. Useful for quick debugging without using a debugger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The function to decorate. |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
The wrapped function. |
Source code in gdutils/utils/decorators.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
timer(func)
Decorator to print the runtime of the decorated function.
It measures the execution time using time.perf_counter() and prints
the result to stdout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The function to decorate. |
required |
Returns:
| Type | Description |
|---|---|
Callable
|
The wrapped function. |
Source code in gdutils/utils/decorators.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |