Commit f2be2a8
committed
perf: buffer accumulation in _write_query_params() and BatchMessage.send_body()
Replace per-parameter write_value(f, param) loops with list.append +
b"".join + single f.write(), reducing f.write() calls from (2*N + 1)
to 1 for N query parameters.
Applied to both:
- _QueryMessage._write_query_params() (execute/query path)
- BatchMessage.send_body() (batch path — entire message in one write)
Also removes the unnecessary super() pass-through in
ExecuteMessage._write_query_params() to eliminate MRO lookup overhead.
Benchmarks (500K iterations, best-of-5, Python 3.14, Cython .so):
128D float32 vector (1 param): 1.25x faster
768D float32 vector (1 param): 1.12x faster
1536D float32 vector (1 param): 1.11x faster
10 text columns: 1.30x faster
Includes benchmark script and 21 unit tests covering execute, query,
and batch message paths.1 parent 8e6c4d4 commit f2be2a8
3 files changed
Lines changed: 908 additions & 37 deletions
0 commit comments