Skip to content

Commit fead15c

Browse files
jahnvi480Copilot
andauthored
PERF: Reduce Python Row indexing overhead (#822)
### Work Item / Issue Reference [AB#48366](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/48366) ### Summary Add a two-line fast path in `Row.__getitem__` for indexes whose exact type is `int`, returning the stored value directly. Keep the existing fallback order unchanged for booleans, integer subclasses, slices and column-name access. Only `mssql_python/row.py` changes. No public API, native code, tests, build configuration or CI changes are included. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent d849a09 commit fead15c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎mssql_python/row.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ def _apply_output_converters_optimized(self, values, converter_map):
222222

223223
def __getitem__(self, index) -> Any:
224224
"""Allow accessing by numeric index (row[0]) or column name (row["col"])."""
225+
if type(index) is int:
226+
return self._values[index]
225227
if isinstance(index, str):
226228
# A row built without a column map has no named columns, so any
227229
# string key is simply absent (KeyError), never a TypeError.

0 commit comments

Comments
 (0)