From 40b26ab256a70585117141584b1e4a1e93a1c523 Mon Sep 17 00:00:00 2001 From: Jahnvi Thakkar Date: Mon, 28 Sep 2026 09:34:05 +0530 Subject: [PATCH] PERF: Reduce Python Row indexing overhead 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> --- mssql_python/row.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mssql_python/row.py b/mssql_python/row.py index 79427067f..ccec53787 100644 --- a/mssql_python/row.py +++ b/mssql_python/row.py @@ -222,6 +222,8 @@ def _apply_output_converters_optimized(self, values, converter_map): def __getitem__(self, index) -> Any: """Allow accessing by numeric index (row[0]) or column name (row["col"]).""" + if type(index) is int: + return self._values[index] if isinstance(index, str): # A row built without a column map has no named columns, so any # string key is simply absent (KeyError), never a TypeError.