MCPcopy Create free account
hub / github.com/apache/arrow / test_native_file_TextIOWrapper_perf

Function test_native_file_TextIOWrapper_perf

python/pyarrow/tests/test_io.py:1466–1480  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

1464
1465
1466def 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
1483def test_native_file_read1(tmpdir):

Callers

nothing calls this directly

Calls 2

lenFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected