aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/pathlib/_local.py
diff options
context:
space:
mode:
authorCody Maloney <cmaloney@users.noreply.github.com>2024-08-16 13:52:41 -0700
committerGitHub <noreply@github.com>2024-08-16 13:52:41 -0700
commit35d8ac7cd7ed6cd3d84af721dce970da59bd5f68 (patch)
treef0a62a11bd75e8b0c0be17949b0c504fbac13ffd /Lib/pathlib/_local.py
parent8ef358dae1959e2aff8b04fb69b8a36d6da6847a (diff)
downloadcpython-35d8ac7cd7ed6cd3d84af721dce970da59bd5f68.tar.gz
cpython-35d8ac7cd7ed6cd3d84af721dce970da59bd5f68.zip
GH-120754: Disable buffering in Path.read_bytes (#122111)
`Path.read_bytes()` is used to read a whole file. buffering / BufferedIO is focused around making small, possibly interleaved, read/write efficient which doesn't add value in this case. On my Mac, running the benchmark: ```python import pyperf from pathlib import Path def read_all(all_paths): for p in all_paths: p.read_bytes() def read_file(path_obj): path_obj.read_bytes() all_rst = list(Path("Doc").glob("**/*.rst")) all_py = list(Path(".").glob("**/*.py")) assert all_rst, "Should have found rst files" assert all_py, "Should have found python source files" runner = pyperf.Runner() runner.bench_func("read_file_small", read_file, Path("Doc/howto/clinic.rst")) runner.bench_func("read_file_large", read_file, Path("Doc/c-api/typeobj.rst")) ``` before: ```python ..................... read_file_small: Mean +- std dev: 6.80 us +- 0.07 us ..................... read_file_large: Mean +- std dev: 10.8 us +- 0.2 us ```` after: ```python ..................... read_file_small: Mean +- std dev: 5.67 us +- 0.05 us ..................... read_file_large: Mean +- std dev: 9.77 us +- 0.52 us ```
Diffstat (limited to 'Lib/pathlib/_local.py')
0 files changed, 0 insertions, 0 deletions