bpo-43317: Use io.DEFAULT_BUFFER_SIZE instead of 1024 in gzip CLI (#24645)

This improves the performance slightly.
This commit is contained in:
Ruben Vorderman 2021-02-26 13:17:51 +01:00 committed by GitHub
parent 25935a2881
commit 7956ef8849
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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)

View file

@ -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.