Commit 50389df
committed
pythongh-12005: Align FileIO.readall between _pyio and _io
Utilize `bytearray.resize()` and `os.readinto()` to reduce copies
and match behavior of `_io.FileIO.readall()`.
There is still an extra copy which means twice the memory required
compared to FileIO because there isn't a zero-copy path from
`bytearray` -> `bytes` currently.
On my system reading a 2GB file
`./python -m test -M8g -uall test_largefile -m test.test_largefile.PyLargeFileTest.test_large_read -v`
Goes from ~2.7 seconds -> ~2.2 seconds1 parent cdcacec commit 50389df
2 files changed
Lines changed: 21 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1674 | 1674 | | |
1675 | 1675 | | |
1676 | 1676 | | |
1677 | | - | |
| 1677 | + | |
| 1678 | + | |
1678 | 1679 | | |
1679 | | - | |
1680 | | - | |
1681 | | - | |
1682 | | - | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
1683 | 1692 | | |
1684 | | - | |
| 1693 | + | |
1685 | 1694 | | |
1686 | | - | |
| 1695 | + | |
1687 | 1696 | | |
1688 | 1697 | | |
1689 | | - | |
| 1698 | + | |
1690 | 1699 | | |
1691 | | - | |
1692 | | - | |
| 1700 | + | |
| 1701 | + | |
1693 | 1702 | | |
1694 | 1703 | | |
1695 | 1704 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments