import pathlib
import xxhash


def _get_xxhash(file_path: pathlib.Path) -> str:
    """Compute the hash of the content of file_pathpath"""
    n = file_path.stat().st_size
    x = xxhash.xxh128()
    m = 2 ** 23  # read 8MB each time
    with file_path.open('rb') as f:
        if n < m * 128: # <= 1GB, check the whole data
            while True:
                data = f.read(m)
                if not data: break
                x.update(data)
        else:
            for _ in range(64):  # check the first 0.5GB
                x.update(f.read(m))
            f.seek(-64*m, 2)
            for _ in range(64):  # check the last 0.5GB
                x.update(f.read(m))
    return x.hexdigest()