Path.chunks(size, *args, **kwargs)[source]
Returns a generator yielding chunks of the file, so it can

be read piece by piece with a simple for loop.

Any argument you pass after size will be passed to open().

>>> hash = hashlib.md5()
>>> for chunk in Path("NEWS.rst").chunks(8192, mode='rb'):
...     hash.update(chunk)

This will read the file by chunks of 8192 bytes.