Mailing List Archive

bpo-43317: Use io.DEFAULT_BUFFER_SIZE instead of 1024 in gzip CLI (#24645)
https://github.com/python/cpython/commit/7956ef884965ac6f9f7f2a27b835ea80e471c886
commit: 7956ef884965ac6f9f7f2a27b835ea80e471c886
branch: master
author: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
committer: methane <songofacandy@gmail.com>
date: 2021-02-26T21:17:51+09:00
summary:

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

This improves the performance slightly.

files:
A Misc/NEWS.d/next/Library/2021-02-25-09-08-55.bpo-43317.qrOOpB.rst
M Lib/gzip.py

diff --git a/Lib/gzip.py b/Lib/gzip.py
index ee0cbed8f50d6..136915725ab4f 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -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
index 0000000000000..01ff48ad90d6b
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-02-25-09-08-55.bpo-43317.qrOOpB.rst
@@ -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.

_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins