Skip to content

Commit

Permalink
bpo-43317: Use io.DEFAULT_BUFFER_SIZE instead of 1024 in gzip CLI (py…
Browse files Browse the repository at this point in the history
…thon#24645)

This improves the performance slightly.
  • Loading branch information
rhpvorderman authored and adorilson committed Mar 11, 2021
1 parent e089525 commit 4e5f175
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def main():
f = builtins.open(arg, "rb")
g = open(arg + ".gz", "wb")
while True:
chunk = f.read(1024)
chunk = f.read(io.DEFAULT_BUFFER_SIZE)
if not chunk:
break
g.write(chunk)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Set the chunk size for the ``gzip`` module main function to
io.DEFAULT_BUFFER_SIZE. This is slightly faster than the 1024 bytes constant
that was used previously.

0 comments on commit 4e5f175

Please sign in to comment.