A small optimization to the Cython implementation of :class:`.ResultProxy`
using a cdef for a particular int value to avoid Python overhead. Pull
request courtesy Matus Valo.
Fixes: #9343
Closes: #9344
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9344
Pull-request-sha:
fc6a97debe45497ef502f3861611b021a5885b63
Change-Id: I231d4fb292decfe9bccdf54f2851ce6f69d5d6c7
--- /dev/null
+.. change::
+ :tags: engine, performance
+ :tickets: 9343
+
+ A small optimization to the Cython implementation of :class:`.ResultProxy`
+ using a cdef for a particular int value to avoid Python overhead. Pull
+ request courtesy Matus Valo.
+
import operator
cdef int MD_INDEX = 0 # integer index in cursor.description
+cdef int _KEY_OBJECTS_ONLY = 1
KEY_INTEGER_ONLY = 0
-KEY_OBJECTS_ONLY = 1
+KEY_OBJECTS_ONLY = _KEY_OBJECTS_ONLY
cdef class BaseRow:
cdef readonly object _parent
if mdindex is None:
self._parent._raise_for_ambiguous_column_name(rec)
elif (
- self._key_style == KEY_OBJECTS_ONLY
+ self._key_style == _KEY_OBJECTS_ONLY
and isinstance(key, int)
):
raise KeyError(key)