def count_bytes_in_file(filepath):
    """Count the number of bytes in a file

    To do so: open the file in read and binary mode, read the content in memory
    and return the length of the resulting bytes string.

    Note that there are more efficient ways to do this but this is just to
    illustrate that you can read the raw bytes of a file in Python and
    therefore compute the file size this way, even for text files.
    """
    with open(filepath, mode='rb') as f:
        binary_content = f.read()

    # Or equivalently:
    #
    #   from patlib import Path
    #
    #   filepath = Path(filepath)
    #   binary_content = filepath.read_bytes()
    #
    return len(binary_content)