You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 05b3775
Browse filesBrowse the repository at this point in the historyBrowse files
perf(spanner): optimize single-chunk results and single-row lookups (#18602)
Optimize the streamed result set decoding pipeline for point queries and
small result sets, and fix async support in `to_dict_list()`.
Key changes:
- Zero-copy protobuf values: In `_consume_next()`, avoid copying
`response_pb.values` into a Python list on unchunked responses.
Downstream decoders read or slice directly from the protobuf container.
- Fast paths in `_merge_values()`:
- Point lookups (`total_values == width`): Directly decode and append
the single row via `_append_single_row()`, bypassing row count
arithmetic, stride looping, and index allocations.
- Complete chunks (`total_values % width == 0`): Skip partial-row
checking and directly batch-decode complete rows.
- Single-indexing in eager decoding: Cache cell lookups using the walrus
operator `(cell := values[...])` instead of indexing twice.
- Direct consumption in `one()` / `one_or_none()`: Replace the generator
state machine and iterator setup with a direct `_consume_next()` loop,
reducing latency on point queries and avoiding Python 3.14 async
generator cleanup warnings when queries short-circuit.
- Faster, async-safe `to_dict_list()`:
- Cache the column name list once on row 0 instead of re-inspecting
protobuf metadata on every row (~2x speedup).
- Add `@CrossSync.convert` with `async for` in `_async/streamed.py`,
fixing a latent bug where calling `to_dict_list()` on an async streamed
result set raised a TypeError.
0 commit comments