Debugging and Code Utilities

gd.utils.breakpoint(message: Optional[str] = None, *, prompt: str = '(dbg) ')None[source]

Drop into the debugger at the call site.

gd.utils.time_execution(function: Callable[[], T], *args, **kwargs)Tuple[T, datetime.timedelta][source]

Execute given function with args and kwargs and measure elapsed time.

Parameters
  • function (Callable[…, T]) – Function to call.

  • *args – Arguments to call function with.

  • **kwargs – Keyword arguments to call function with.

Returns

Tuple: result of the function and time elapsed.

Return type

Tuple[T, datetime.timedelta]

gd.utils.time_execution_and_print(function: Callable[[], T], *args, **kwargs)T[source]

Execute given function with args and kwargs and print elapsed time.

Prints a message like Executed function_name in 0:00:00.001000.

Parameters
  • function (Callable[…, T]) – Function to call.

  • *args – Arguments to call function with.

  • **kwargs – Keyword arguments to call function with.

Returns

Result that the function returns.

Return type

T

gd.utils.unreachable()NoReturn[source]

Indicates the code that is unreachable.

Raises

RuntimeError – Error that is raised when, for some reason, this function is called.

gd.utils.print_source(some_object: Any)None[source]

Attempt to find and print source of the object, and do nothing on fail.