dbg

Module Contents

Classes

MemSizeType

Create a collection of name/value pairs.

MemSize

Convert a string or number to a floating point number, if possible.

Functions

get_size(test_obj[, size_type])

explore_sizes(test_obj[, size_type, max_level, ...])

print_size(test_obj[, size_type])

profile(fnc)

A decorator that uses cProfile to profile a function

prepare_text(debug_print[, debug_from])

p(debug_print[, debug_from])

Prints text to terminal for debugging.

u(debug_print[, debug_from, end])

Updates the colourised string of the terminal with debug_print. If end is True the line is ended

Attributes

has_asizeof

RUNTIME_CONSOLE

EXCLUSION_TYPES

EXCLUSION_MODULES

dbg.has_asizeof = 'True'[source]
dbg.RUNTIME_CONSOLE = 'True'[source]
dbg.EXCLUSION_TYPES[source]
dbg.EXCLUSION_MODULES = "['numpy', 'h5py', 'h5pickle']"[source]
class dbg.MemSizeType(*args, **kwds)[source]

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

>>> Color.RED
<Color.RED: 1>
  • value lookup:

>>> Color(1)
<Color.RED: 1>
  • name lookup:

>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

byte[source]
bit[source]
kilobyte[source]
kilobit[source]
megabyte[source]
megabit[source]
gigabyte[source]
gigabit[source]
class dbg.MemSize(value: int | float, size_type: str | MemSizeType = MemSizeType.megabyte)[source]

Bases: float

Convert a string or number to a floating point number, if possible.

size_type[source]
in_mb() float[source]
static str_2_size_type(type_str: str)[source]
static size_type_2_str(size_type: MemSizeType)[source]
__str__()[source]

Return str(self).

dbg.get_size(test_obj: object, size_type: str | MemSizeType = MemSizeType.megabyte)[source]
dbg.explore_sizes(test_obj: object, size_type: str | MemSizeType = MemSizeType.megabyte, max_level=5, min_size_mb=None, stop_on_max_level=True, exclusion_types=None, exclusion_modules=None, only_show_new=False, __current_level=0, __objs_tested=None)[source]
dbg.print_size(test_obj: object, size_type: str | MemSizeType = MemSizeType.megabyte)[source]
dbg.profile(fnc)[source]

A decorator that uses cProfile to profile a function

dbg.prepare_text(debug_print, debug_from=None)[source]
dbg.p(debug_print, debug_from=None)[source]

Prints text to terminal for debugging.

dbg.u(debug_print: str, debug_from: str = None, end: bool = False)[source]
Updates the colourised string of the terminal with debug_print. If end is True the line is ended
debug_print: str

Test to be used updated the terminal with.

debug_from: str, optional

To specify where debug text is being called from.

end: str, optional

If true the line is ended.