Skip to content

gh-129813, PEP 782: Use PyBytesWriter in _io.FileIO.readall - #138901

Merged
vstinner merged 3 commits into
python:mainfrom
cmaloney:pep782_fileio
Sep 15, 2025
Merged

vstinner merged 3 commits into
python:mainfrom
cmaloney:pep782_fileio

Conversation

@cmaloney

@cmaloney cmaloney commented Sep 15, 2025 •

Copy link
Copy Markdown
Contributor

Performance largely flat, maybe faster on bm_readall.py from gh-120754 (read all python docs and py files using readall).

$ pyperf compare_to main.json pep782.json
read_file_small: Mean +- std dev: [main] 5.71 us +- 0.05 us -> [pep782] 5.68 us +- 0.05 us: 1.01x faster
read_file_large: Mean +- std dev: [main] 89.7 us +- 0.9 us -> [pep782] 86.9 us +- 0.8 us: 1.03x faster
read_all_rst_bytes: Mean +- std dev: [main] 926 us +- 8 us -> [pep782] 920 us +- 12 us: 1.01x faster
read_all_rst_text: Mean +- std dev: [main] 2.24 ms +- 0.02 ms -> [pep782] 2.17 ms +- 0.04 ms: 1.03x faster

Benchmark hidden because not significant (1): read_all_py_bytes

Geometric mean: 1.01x faster
Performance about the same, using the benchmark from pythongh-120754:

```
pyperf compare_to main.json pep782.json
read_file_small: Mean +- std dev: [main] 5.71 us +- 0.05 us -> [pep782] 5.68 us +- 0.05 us: 1.01x faster
read_file_large: Mean +- std dev: [main] 89.7 us +- 0.9 us -> [pep782] 86.9 us +- 0.8 us: 1.03x faster
read_all_rst_bytes: Mean +- std dev: [main] 926 us +- 8 us -> [pep782] 920 us +- 12 us: 1.01x faster
read_all_rst_text: Mean +- std dev: [main] 2.24 ms +- 0.02 ms -> [pep782] 2.17 ms +- 0.04 ms: 1.03x faster

Benchmark hidden because not significant (1): read_all_py_bytes

Geometric mean: 1.01x faster
```

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I suggest removing the NEWS entry.

@vstinner
vstinner merged commit 71defb6 into python:main Sep 15, 2025
@cmaloney
cmaloney deleted the pep782_fileio branch September 15, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants