def human_readable_size(size, precision=0):
    """ Convert size in bytes to a more readable form. """
    i, units = 0, ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
    while size > 1024 and i < len(units):
        i += 1
        size /= 1024
    return '%.*f%s' % (precision, size, units[i])
