Repository navigation
PERF: Reduce Python Row indexing overhead - #822
Conversation
Fast-path exact built-in integer indexes while preserving the existing ordered fallback for other index types. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PR Performance Report✅ No regression detectedNo consistent slowdowns detected across all 2 environments. 0 IMPROVEMENTS 0 SLOWDOWNS 2/2 ENVIRONMENTS Coverage: 2 of 2 environments completed. Advisory result; does not block merging. Performance diagnosticsPhase times are inclusive diagnostics and must not be added together. They identify where measured time changed, not why it changed. No affected phases or call-count changes were recorded. All database tasks and timingsUnix / SQL Server 2022
Unix / SQL Server 2025
Build and measurement detailsPR head:
A consistent change requires more than 20% median paired movement, at least 1 ms between the median runtimes, and at least 80% of pairs exceeding the relative threshold in the same direction. A slowdown without enough pair agreement is reported as inconsistent. The displayed change is the median of paired before-and-after ratios. It is not recalculated from the two displayed median runtimes. Both revisions use profiling-enabled builds on the same agent and database, with alternating order and discarded warmups. Results are diagnostic and do not represent production-wheel latency. Raw samples and logs are attached to the ADO run as |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Add regression coverage for boolean and integer-subclass indexing and provide current-main performance validation.
Review effort: Lite
Findings: None
What changed in this PR
Adds an exact-int fast path to Row.__getitem__ to reduce positional indexing overhead while preserving fallback behavior.
Changes:
- Directly returns stored values for exact integer indexes.
- Retains existing handling for booleans, integer subclasses, slices, and column names.
- Adds no API, native, build, or CI changes.
| File | Description |
|---|---|
mssql_python/row.py |
Adds the positional integer indexing fast path. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 62.6%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 79.3%
mssql_python.pybind.connection.connection_pool.cpp: 82.3%
mssql_python.pybind.connection.connection.cpp: 83.1%
mssql_python.logging.py: 86.2%
mssql_python.pooling.py: 90.1%
mssql_python.pybind.fetch_temporal.hpp: 92.1%🔗 Quick Links
|

Work Item / Issue Reference
AB#48366
Summary
Add a two-line fast path in
Row.__getitem__for indexes whose exact type isint, returning the stored value directly. Keep the existing fallback order unchanged for booleans, integer subclasses, slices and column-name access.Only
mssql_python/row.pychanges. No public API, native code, tests, build configuration or CI changes are included.