file_hash.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:binaryalert 作者: airbnb 项目源码 文件源码
def _read_in_chunks(file_object: IO[bytes], chunk_size: int = 2*MB) -> Generator[bytes, None, None]:
    """Read a file in fixed-size chunks (to minimize memory usage for large files).

    Args:
        file_object: An opened file-like object supporting read().
        chunk_size: Max size (in bytes) of each file chunk.

    Yields:
        File chunks, each of size at most chunk_size.
    """
    while True:
        chunk = file_object.read(chunk_size)
        if chunk:
            yield chunk
        else:
            return  # End of file.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号