pandas .values.tolist() is ~1.92× slower than polars .rows() for turning rows into Python objects
Only 2,000 rows are converted, so this measures per-row overhead.
Result
| Run | pandas .values.tolist() | polars .rows() | Ratio |
|---|---|---|---|
| Run 1 | 0.69 | 0.34 | 2.01× |
| Run 2 | 0.65 | 0.34 | 1.92× |
| Run 3 | 0.94 | 0.5 | 1.90× |
Spread over 3 runs: pandas .values.tolist() CV 20.6% / polars .rows() CV 22.8% / ratio CV 3.0%
The two calls
df[['g','v']].head(2000).values.tolist() df.select(['g','v']).head(2000).rows() Conditions
The frame is already in memory.
Where this number does not apply
Converting the whole 400,000-row frame is dominated by allocation, not by per-row overhead.
Reproduce
cd bench && python run.py --run 1 --out ../data/run1.json