| 1464 | |
| 1465 | |
| 1466 | def test_native_file_TextIOWrapper_perf(tmpdir): |
| 1467 | # ARROW-16272: TextIOWrapper.readline() shouldn't exhaust a large |
| 1468 | # Arrow input stream. |
| 1469 | data = b'foo\nquux\n' |
| 1470 | path = str(tmpdir / 'largefile.txt') |
| 1471 | with open(path, 'wb') as f: |
| 1472 | f.write(data * 100_000) |
| 1473 | |
| 1474 | binary_file = pa.OSFile(path, mode='rb') |
| 1475 | with TextIOWrapper(binary_file) as f: |
| 1476 | assert binary_file.tell() == 0 |
| 1477 | nbytes = 20_000 |
| 1478 | lines = f.readlines(nbytes) |
| 1479 | assert len(lines) == math.ceil(2 * nbytes / len(data)) |
| 1480 | assert nbytes <= binary_file.tell() <= nbytes * 2 |
| 1481 | |
| 1482 | |
| 1483 | def test_native_file_read1(tmpdir): |