module helpers.size_helper
#
Short summary#
module ensae_teaching_cs.helpers.size_helper
Functions to measure the size of an object.
Functions#
function |
truncated documentation |
---|---|
Calls getsizeof. |
|
Returns the approximate memory footprint an object and all of its contents. |
Documentation#
Functions to measure the size of an object.
- ensae_teaching_cs.helpers.size_helper.object_size(o)#
Calls getsizeof.
- Paramètres:
o – object
- Renvoie:
size of the object, that excludes references objects.
- ensae_teaching_cs.helpers.size_helper.total_size(o, handlers=None)#
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.