From f90ac943cfba3b0140324adf7b1e2b482eea25f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sun, 13 Feb 2022 20:21:28 +0100 Subject: [PATCH] Use blake3 instead of blake2 for a considerable performance increase Based on some rough benchmarking performed on reasonably modern, but not over the top laptop hardware (i7-8665U + PCIe3 NVMe SSD) this results in raw disk io (+ tar overhead) becoming the performance bottleneck instead of hashing rate. --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 8b424c6..53c679b 100755 --- a/main.py +++ b/main.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 from sys import stdin from sys import exit as sysexit -from hashlib import blake2b from io import BytesIO from subprocess import Popen, PIPE import click +from blake3 import blake3 from identicon import Identicon @@ -86,10 +86,11 @@ def print_usage_and_exit(): def get_digest(stream): - hasher = blake2b(digest_size=DIGEST_SIZE) + # pylint: disable=not-callable + hasher = blake3() while data := stream.read(BUF_SIZE): hasher.update(data) - return hasher.digest() + return hasher.digest(length=DIGEST_SIZE)