Skip to content

Commit

Permalink
Use sha1 for hashing (#17953)
Browse files Browse the repository at this point in the history
This is a pretty small win, it's below the noise floor on
macrobenchmark, but if you time the hashing specifically it saves about
100ms (0.5%) on `python -m mypy -c 'import torch' --no-incremental`.
blake2b is slower
  • Loading branch information
hauntsaninja committed Oct 20, 2024
1 parent 2416dbf commit 159974c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mypy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,7 @@ def hash_digest(data: bytes) -> str:
accidental collision, but we don't really care about any of the
cryptographic properties.
"""
# Once we drop Python 3.5 support, we should consider using
# blake2b, which is faster.
return hashlib.sha256(data).hexdigest()
return hashlib.sha1(data).hexdigest()


def parse_gray_color(cup: bytes) -> str:
Expand Down

0 comments on commit 159974c

Please sign in to comment.