File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 22
33from collections import defaultdict
44from collections .abc import Hashable , Iterable
5- from hashlib import sha256
5+ import hashlib
66from typing import Any , DefaultDict , Union , cast
77import warnings
88
7070
7171class Hasher :
7272 def __init__ (self ):
73+ self ._hasher : hashlib ._Hash | xxh64
7374 if HAVE_XXHASH :
7475 self ._hasher = xxh64 ()
75- self ._use_xx = True
76+ self ._use_xxh64 = True
7677 else :
77- self ._hasher = sha256 ()
78- self ._use_xx = False
78+ self ._hasher = hashlib . sha256 ()
79+ self ._use_xxh64 = False
7980
8081 def reset (self ):
81- if self ._use_xx :
82- self ._hasher = xxh64 ()
83- else :
82+ if self ._use_xxh64 :
83+ assert isinstance (self ._hasher , xxh64 )
8484 self ._hasher .reset ()
85+ else :
86+ self ._hasher = hashlib .sha256 ()
8587
8688 def update (self , data : memoryview ) -> None :
8789 self ._hasher .update (data )
You can’t perform that action at this time.
0 commit comments