def format_bytes(num, decimal_places=3):
    """Converts a number of bytes (float/int) into a reader-friendly format.
    Rounds values off to decimal_places decimal places, or to 0 decimal places
    if num < 1000."""
    if num >= 1e9:
        return f"{num/1e9:,.{decimal_places}f} GB"
    elif num >= 1e6:
        return f"{num/1e6:,.{decimal_places}f} MB"
    elif num >= 1e3:
        return f"{num/1e3:,.{decimal_places}f} KB"
    else:
        return f"{num:.0f} bytes"