| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,8 +23,8 @@ | |||
| 23 | 23 | valid_seek_flags.add(os.SEEK_HOLE) | |
| 24 | 24 | valid_seek_flags.add(os.SEEK_DATA) | |
| 25 | 25 | ||
| 26 | - # open() uses st_blksize whenever we can | ||
| 27 | - DEFAULT_BUFFER_SIZE = 8 * 1024 # bytes | ||
| 26 | + # open() uses max(st_blksize, io.DEFAULT_BUFFER_SIZE) when st_blksize is available | ||
| 27 | + DEFAULT_BUFFER_SIZE = 128 * 1024 # bytes | ||
| 28 | 28 | ||
| 29 | 29 | # NOTE: Base classes defined here are registered with the "official" ABCs | |
| 30 | 30 | # defined in io.py. We don't use real inheritance though, because we don't want | |
@@ -249,7 +249,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None, | |||
| 249 | 249 | pass | |
| 250 | 250 | else: | |
| 251 | 251 | if bs > 1: | |
| 252 | - buffering = bs | ||
| 252 | + buffering = max(bs, DEFAULT_BUFFER_SIZE) | ||
| 253 | 253 | if buffering < 0: | |
| 254 | 254 | raise ValueError("invalid buffering size") | |
| 255 | 255 | if buffering == 0: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + Increase ``io.DEFAULT_BUFFER_SIZE`` from 4k/8k to 128k. Adapt :func:`open` on Linux to use | ||
| 2 | + ``max(io.DEFAULT_BUFFER_SIZE, device block size)`` rather than the device block | ||
| 3 | + size. Improve I/O performance upto 3 to 5 times. Patch by Romain Morotti. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,7 +78,7 @@ extern Py_ssize_t _PyIO_find_line_ending( | |||
| 78 | 78 | */ | |
| 79 | 79 | extern int _PyIO_trap_eintr(void); | |
| 80 | 80 | ||
| 81 | - #define DEFAULT_BUFFER_SIZE (8 * 1024) /* bytes */ | ||
| 81 | + #define DEFAULT_BUFFER_SIZE (128 * 1024) /* bytes */ | ||
| 82 | 82 | ||
| 83 | 83 | /* | |
| 84 | 84 | * Offset type for positioning. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments