in memory_analyzer/frontend/frontend_utils.py [0:0]
def readable_size(i, snapshot=False):
"""
Pretty-print the integer `i` as a human-readable size representation.
"""
degree = 0
while i > 1024:
i = i / float(1024)
degree += 1
scales = ["B", "KB", "MB", "GB", "TB", "EB"]
if snapshot:
return f"{i:+.2f}{scales[degree]:>5}"
return f"{i:.2f}{scales[degree]:>5}"