absfuyu.util.performance module

Absfuyu: Performance

Performance Check

Version: 5.1.0 Date updated: 10/03/2025 (dd/mm/yyyy)

Feature:

  • measure_performance

  • function_debug

  • retry

  • var_check

  • Checker

absfuyu.util.performance.function_debug(f: Callable[[P], R]) Callable[[P], R][source]

Print the function signature and return value

Parameters:

func (Callable) – Function to debug

Returns:

A decorated function

Return type:

Callable

Usage

Use this as a decorator (@function_debug)

Example:

>>> @function_debug
>>> def test(a: int, b: int):
...     return a + b
>>> test(6, 8)
Calling test(6, 8)
test() returned 14

Added in version 3.2.0

absfuyu.util.performance.measure_performance(f: Callable[[P], R]) Callable[[P], R][source]

Measure performance of a function

Parameters:

f (Callable [P, R]) – Function to measure

Returns:

A decorated function

Return type:

Callable

Usage

Use this as a decorator (@measure_performance)

Example:

>>> @measure_performance
>>> def test():
...     return 1 + 1
>>> test()
    --------------------------------------
    Function: test
    Memory usage:            0.000000 MB
    Peak memory usage:       0.000000 MB
    Time elapsed (seconds):  0.000002
    --------------------------------------

Changed in version 3.2.0: Updated functionality

absfuyu.util.performance.retry(retries: int, delay: float = 1)[source]

Attempt to call a function, if it fails, try again with a specified delay.

Parameters:
  • retries (int) – The max amount of retries you want for the function call

  • delay (int) – The delay (in seconds) between each function retry

Returns:

A decorated function

Return type:

Callable

Usage

Use this as a decorator (@retry)

Example:

>>> @retry(retries=3, delay=1)
>>> def test() -> None:
...     time.sleep(1)
...     raise Exception("Function error")
>>> test()
Running (1): test()
Error: Exception('Function error') -> Retrying...
Running (2): test()
Error: Exception('Function error') -> Retrying...
Running (3): test()
Error: Exception('Function error').
"test()" failed after 3 retries.

Added in version 3.2.0

class absfuyu.util.performance.Checker(variable: Any)[source]

Bases: object

Check a variable

Parameters:

variable (Any) – Variable that needed to check

Example:

>>> test = "test"
>>> Checker(test).check()
{'name': None, 'value': 'test', 'class': <class 'str'>, 'id': ...}

Deprecated in version 5.1.0: Use `absfuyu.tools.inspector` instead

property name: Any | None

__name__ of variable (if any)

property value: Any

Value of the variable

property docstring: str | None

__doc__ of variable (if any)

property class_: Any

class() of variable

property id_: int

id() of variable

property dir_: list[str]

dir() of variable

property source: str | None

Source code of variable (if available)

check(full: bool = False) dict[str, Any][source]

Check the variable

Parameters:

full (bool) –

True: Shows full detail
False: Hides dir, docstring and source code
Default: False

Returns:

Check result

Return type:

dict[str, Any]