def update_hash ( cls , filelike , digest ) : block_size = digest . block_size * 1024 for chunk in iter ( lambda : filelike . read ( block_size ) , b'' ) : digest . update ( chunk )
python file reading an efficient block size
Update the digest of a single file in a memory - efficient manner .
def update_hash(cls, filelike, digest):
    """Update the digest of a single file in a memory-efficient manner."""
    block_size = digest.block_size * 1024
    for chunk in iter(lambda: filelike.read(block_size), b''):
      digest.update(chunk)