Skip to content

Commit 6f67de7

Browse files
committed
Read chunks in Python's default buffer size
I observed minor performance improvements by using this larger chunk read size. Python's docs describe `io.DEFAULT_BUFFER_SIZE` as: > An int containing the default buffer size used by the module’s > buffered I/O classes. open() uses the file’s blksize ... The docs on `blksize` say: > “Preferred” blocksize for efficient file system I/O. Writing to a file > in smaller chunks may cause an inefficient read-modify-rewrite. References: - https://docs.python.org/3/library/io.html#io.DEFAULT_BUFFER_SIZE - https://docs.python.org/3/library/os.html#os.stat_result.st_blksize
1 parent 75fbed7 commit 6f67de7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

invoke/runners.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import errno
22
import locale
3+
import io
34
import os
45
import struct
56
import sys
@@ -71,7 +72,7 @@ class Runner:
7172

7273
opts: Dict[str, Any]
7374
using_pty: bool
74-
read_chunk_size = 1000
75+
read_chunk_size = io.DEFAULT_BUFFER_SIZE
7576
input_sleep = 0.01
7677

7778
def __init__(self, context: "Context") -> None:

0 commit comments

Comments
 (0)