Skip to content

Commit

Permalink
Use sha1 for hashing (python#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 authored Oct 15, 2024
1 parent 676ed06 commit 284677e
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 @@ -534,9 +534,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 284677e

Please sign in to comment.