getObjectSize

lsst.daf.butler.core.utils.getObjectSize(obj, seen=None)

Recursively finds size of objects.

Only works well for pure python objects. For example it does not work for Exposure objects where all the content is behind getter methods.

Parameters:
obj : object

Instance for which size is to be calculated.

seen : set, optional

Used internally to keep track of objects already sized during recursion.

Returns:
size : int

Size in bytes.

See also

sys.getsizeof

Notes

See https://goshippo.com/blog/measure-real-size-any-python-object/