module helpers.size_helper

Short summary

module ensae_teaching_cs.helpers.size_helper

Functions to measure the size of an object.

source on GitHub

Functions

function

truncated documentation

object_size

Calls getsizeof.

total_size

Returns the approximate memory footprint an object and all of its contents.

Documentation

Functions to measure the size of an object.

source on GitHub

ensae_teaching_cs.helpers.size_helper.object_size(o)[source]

Calls getsizeof.

Paramètres

o – object

Renvoie

size of the object, that excludes references objects.

source on GitHub

ensae_teaching_cs.helpers.size_helper.total_size(o, handlers=None)[source]

Returns the approximate memory footprint an object and all of its contents.

Paramètres
  • o – object to measure

  • handlers – for recursivity purpose

Renvoie

total size

Automatically finds the contents of the following builtin containers and their subclasses: tuple, list, deque, dict, set and frozenset. To search other containers, add handlers to iterate over their contents:

handlers = {SomeContainerClass: iter,
            OtherContainerClass: OtherContainerClass.get_elements}

Source : activestate referenced by function getsizeof.

source on GitHub