Skip to content

Commit 2a59471

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 2034b82 commit 2a59471

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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 signal
56
import struct
@@ -72,7 +73,7 @@ class Runner:
7273

7374
opts: Dict[str, Any]
7475
using_pty: bool
75-
read_chunk_size = 1000
76+
read_chunk_size = io.DEFAULT_BUFFER_SIZE
7677
input_sleep = 0.01
7778

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

0 commit comments

Comments
 (0)