Created
October 9, 2025 04:57
-
-
Save ricardocuellar/76e78ab1514bbca6e7451b3ed84b510f to your computer and use it in GitHub Desktop.
Chunk Reader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class _ChunkCounter: | |
| def __init__(self, f): | |
| self._f = f | |
| self.calls = 0 | |
| self.sizes = [] | |
| def read(self, n=-1): | |
| data = self._f.read(n) | |
| if data: | |
| self.calls += 1 | |
| self.sizes.append(len(data)) | |
| return data | |
| def __getattr__(self, name): # delega cualquier otro atributo | |
| return getattr(self._f, name) | |
| reader = _ChunkCounter(file.file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment