skneuromsi.utils.memtools module

Memory usage and impact analysis tools.

This module provides classes and functions to calculate and represent memory usage and impact of Python objects.

skneuromsi.utils.memtools.memory_usage(obj)[source]

Calculate the memory usage of an object.

Parameters:

obj (object) – The object to calculate memory usage for.

Returns:

An instance of _MemoryUsage containing the calculated memory size.

Return type:

_MemoryUsage

skneuromsi.utils.memtools.memory_impact(obj, *, size_factor=1, num_objects=1)[source]

Calculate the memory impact of an object.

Parameters:
  • obj (object) – The object to calculate memory impact for.

  • num_objects (int, optional) – Number of objects to consider (default is 1).

  • size_factor (float, optional) – Factor to multiply the expected size by (default is 1). Size factor is a factor to multiply the expected size by. It is assumed that most objects are a little bigger or smaller than the expected size. For example, if size_factor=1.2 then the expected size is multiplied by 1.2, this means that most objects will be 20% bigger than the expected size. If size_factor=0.75 then most objects will be 35% smaller.

Returns:

An instance of _MemoryImpact containing the calculated impact metrics.

Return type:

_MemoryImpact