from hashlib import md5 as _md5


def get_filesize_and_checksum(filename):
    """Opens the file with the passed filename and calculates
        its size and md5 hash

       Args:
            filename (str): filename to calculate size and checksum for
        Returns:
            tuple (int,str): size of data and its md5 hash

    """

    md5 = _md5()
    size = 0

    with open(filename, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            md5.update(chunk)
            size += len(chunk)

    return (size, str(md5.hexdigest()))