import hashlib


def md5sum(path):
    """Return the MD5 hash of the file contents.
    """
    BUF_SIZE = 1024 * 64
    buf = bytearray(BUF_SIZE)
    mv = memoryview(buf)
    md5 = hashlib.md5()
    with open(path, 'rb') as fh:
        while True:
            num_bytes = fh.readinto(buf)
            md5.update(mv[:num_bytes])
            if num_bytes < BUF_SIZE:
                break
    return md5.hexdigest()