Skip to content

Commit

Permalink
pythongh-117151: IO performance improvement, increase io.DEFAULT_BUFF…
Browse files Browse the repository at this point in the history
…ER_SIZE to 128k, fix open() to use max(st_blksize, io.DEFAULT_BUFFER_SIZE)

performance:
  • Loading branch information
rmmancom committed Apr 2, 2024
1 parent 9654daf commit e9b2714
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
valid_seek_flags.add(os.SEEK_HOLE)
valid_seek_flags.add(os.SEEK_DATA)

# open() uses st_blksize whenever we can
DEFAULT_BUFFER_SIZE = 8 * 1024 # bytes
# open() uses max(st_blksize, io.DEFAULT_BUFFER_SIZE) when st_blksize is available
DEFAULT_BUFFER_SIZE = 128 * 1024 # bytes

# NOTE: Base classes defined here are registered with the "official" ABCs
# defined in io.py. We don't use real inheritance though, because we don't want
Expand Down Expand Up @@ -249,7 +249,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
pass
else:
if bs > 1:
buffering = bs
buffering = max(bs, DEFAULT_BUFFER_SIZE)
if buffering < 0:
raise ValueError("invalid buffering size")
if buffering == 0:
Expand Down

0 comments on commit e9b2714

Please sign in to comment.