src/main/python/bktools/ext/python/objects.py
def sizeof(obj: Any, seen: Set[Any] = None) -> int:
    """
    Recursively finds size of objects.

    Parameters:
        obj: The object that will be evaluated
        seen: Already visited objects

    Returns:
        The bytes of the object
    """
    size = sys.getsizeof(obj)

    if seen is None:
        seen = set()

    obj_id = id(obj)
    if obj_id in seen:
        return 0

    # Important mark as seen *before* entering recursion to gracefully handle
    # self-referential objects
    seen.add(obj_id)
    if isinstance(obj, dict):
        size += sum([sizeof(v, seen) for v in obj.values()])
        size += sum([sizeof(k, seen) for k in obj.keys()])

    elif hasattr(obj, '__dict__'):
        size += sizeof(obj.__dict__, seen)

    elif hasattr(obj, '__iter__') and not isinstance(obj, (str, bytes, bytearray)):
        size += sum([sizeof(i, seen) for i in obj])

    return size

    Recursively finds size of objects.

    Parameters:
        obj: The object that will be evaluated
        seen: Already visited objects

    Returns:
        The bytes of the object
    
Recursively finds size of objects.
Recursively finds size of objects .
def sizeof(obj: Any, seen: Set[Any] = None) -> int:
    size = sys.getsizeof(obj)
    if seen is None:
        seen = set()
    obj_id = id(obj)
    if obj_id in seen:
        return 0
    seen.add(obj_id)
    if isinstance(obj, dict):
        size += sum([sizeof(v, seen) for v in obj.values()])
        size += sum([sizeof(k, seen) for k in obj.keys()])
    elif hasattr(obj, '__dict__'):
        size += sizeof(obj.__dict__, seen)
    elif hasattr(obj, '__iter__') and not isinstance(obj, (str, bytes, bytearray)):
        size += sum([sizeof(i, seen) for i in obj])
    return size
def sizeof ( obj : Any , seen : Set [ Any ] = None ) -> int : size = sys . getsizeof ( obj ) if seen is None : seen = set ( ) obj_id = id ( obj ) if obj_id in seen : return 0 seen . add ( obj_id ) if isinstance ( obj , dict ) : size += sum ( [ sizeof ( v , seen ) for v in obj . values ( ) ] ) size += sum ( [ sizeof ( k , seen ) for k in obj . keys ( ) ] ) elif hasattr ( obj , '__dict__' ) : size += sizeof ( obj . __dict__ , seen ) elif hasattr ( obj , '__iter__' ) and not isinstance ( obj , ( str , bytes , bytearray ) ) : size += sum ( [ sizeof ( i , seen ) for i in obj ] ) return size
Recursively finds size of objects.
Recursively finds size of objects .
"""
    Recursively finds size of objects.

    Parameters:
        obj: The object that will be evaluated
        seen: Already visited objects

    Returns:
        The bytes of the object
    """ # Important mark as seen *before* entering recursion to gracefully handle # self-referential objects
The bytes of the object
The bytes of the object
obj
Any
The object that will be evaluated
The object that will be evaluated
seen
Set[Any]
Already visited objects
Already visited objects