def readable_mem(mem):
    """
    :param mem: An integer number of bytes to convert to human-readable form.
    :return: A human-readable string representation of the number.
    """
    for suffix in ["", "K", "M", "G", "T"]:
        if mem < 10000:
            return f"{int(mem)}{suffix}"
        mem /= 1024
    return f"{int(mem)}P"
:param mem: An integer number of bytes to convert to human-readable form.
:return: A human-readable string representation of the number.
asciimatics/utilities.py