10000 bpo-43317: Use io.DEFAULT_BUFFER_SIZE instead of 1024 in gzip CLI (#2… · python/cpython@7956ef8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7956ef8

Browse files
authored
bpo-43317: Use io.DEFAULT_BUFFER_SIZE instead of 1024 in gzip CLI (#24645)
This improves the performance slightly.
1 parent 25935a2 commit 7956ef8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/gzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def main():
595595
f = builtins.open(arg, "rb")
596596
g = open(arg + ".gz", "wb")
597597
while True:
598-
chunk = f.read(1024)
598+
chunk = f.read(io.DEFAULT_BUFFER_SIZE)
599599
if not chunk:
600600
break
601601
g.write(chunk)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Set the chunk size for the ``gzip`` module main function to
2+
io.DEFAULT_BUFFER_SIZE. This is slightly faster than the 1024 bytes constant
3+
that was used previously.

0 commit comments

Comments
 (0)
0