]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43317: Use io.DEFAULT_BUFFER_SIZE instead of 1024 in gzip CLI (#24645)
authorRuben Vorderman <r.h.p.vorderman@lumc.nl>
Fri, 26 Feb 2021 12:17:51 +0000 (13:17 +0100)
committerGitHub <noreply@github.com>
Fri, 26 Feb 2021 12:17:51 +0000 (21:17 +0900)
This improves the performance slightly.

Lib/gzip.py
Misc/NEWS.d/next/Library/2021-02-25-09-08-55.bpo-43317.qrOOpB.rst [new file with mode: 0644]

index ee0cbed8f50d6d827099ce8d333403f6cbea8645..136915725ab4f9c8fe491d39fe7c873e1e9eeaa0 100644 (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)
diff --git a/Misc/NEWS.d/next/Library/2021-02-25-09-08-55.bpo-43317.qrOOpB.rst b/Misc/NEWS.d/next/Library/2021-02-25-09-08-55.bpo-43317.qrOOpB.rst
new file mode 100644 (file)
index 0000000..01ff48a
--- /dev/null
@@ -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.