You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gzip.GzipFile uses the BufferedIOBase implementation of .readinto(), which simply calls .read and copies the result into a buffer. This negates the purpose of using .readinto() at all.
This may be considered more a missed optimization than a bug, but it is being reported in downstream tools and I've traced it back to CPython.
Bug report
Bug description:
gzip.GzipFile uses the BufferedIOBase implementation of
.readinto()
, which simply calls.read
and copies the result into a buffer. This negates the purpose of using.readinto()
at all.This may be considered more a missed optimization than a bug, but it is being reported in downstream tools and I've traced it back to CPython.
Current memory profile
Duration: 0:00:01.821000
Total number of allocations: 5064
Total number of frames seen: 85
Peak memory usage: 116.3 MiB
Python allocator: pymalloc
Patched memory profile
Duration: 0:00:01.828000
Total number of allocations: 3317
Total number of frames seen: 79
Peak memory usage: 66.2 MiB
Python allocator: pymalloc
Patch
I believe this should be an uncontroversial patch, so I will open a PR immediately.
cc @psadil
CPython versions tested on:
3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: