Skip to content

Commit bcb2438

Browse files
paddymulclaude
andcommitted
style: wrap long lines in bench_scan_order.py to satisfy ruff E501
Convert the read and group_by benchmark lambdas to inner functions and hoist the polars label out of the f-string, keeping every line under the 120-char limit. CI ruff check flagged lines 80, 114, 116. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 52eb313 commit bcb2438

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

scripts/bench_scan_order.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ def section_read(csv, schema, runs):
7777
out = {}
7878
for label, configure in VARIANTS:
7979
con = _make_backend(configure)
80-
wall, cpu, n = _best(runs, lambda: sum(b.num_rows for b in con.read_csv(csv, schema=schema).to_pyarrow_batches()))
80+
81+
def run():
82+
t = con.read_csv(csv, schema=schema)
83+
return sum(b.num_rows for b in t.to_pyarrow_batches())
84+
85+
wall, cpu, n = _best(runs, run)
8186
out[label] = (wall, cpu / wall)
8287
print(f" {label:<44} {wall:6.2f}s {cpu / wall:5.1f} cores rows={n:,}", flush=True)
8388

@@ -111,9 +116,14 @@ def run():
111116
out[(gcol, label)] = (wall, cpu / wall)
112117
print(f" {label:<44} {wall:6.2f}s {cpu / wall:5.1f} cores groups={g:,}", flush=True)
113118

114-
wall, cpu, g = _best(runs, lambda: pl.scan_csv(csv, infer_schema=False).group_by(gcol).agg(pl.len()).collect().height)
119+
def run_pl():
120+
lf = pl.scan_csv(csv, infer_schema=False)
121+
return lf.group_by(gcol).agg(pl.len()).collect().height
122+
123+
wall, cpu, g = _best(runs, run_pl)
115124
out[(gcol, "polars group_by.agg.collect()")] = (wall, cpu / wall)
116-
print(f" {'polars group_by.agg.collect()':<44} {wall:6.2f}s {cpu / wall:5.1f} cores groups={g:,}", flush=True)
125+
pl_label = "polars group_by.agg.collect()"
126+
print(f" {pl_label:<44} {wall:6.2f}s {cpu / wall:5.1f} cores groups={g:,}", flush=True)
117127
return out
118128

119129

0 commit comments

Comments
 (0)