FEAT: adding perf improvements #311
Draft
+476
−254
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request introduces several performance and maintainability improvements to the MSSQL Python driver, focusing on optimizing row creation, reducing repeated lookups of Python types and settings, and ensuring proper cursor configuration. The changes span both the Python and C++ layers, with new caching mechanisms and more efficient resource usage.
Python-side row creation optimizations
Cursorclass to avoid repeated computation during row fetching. These caches are now built and reused for all fetch operations (fetchone,fetchmany,fetchall). [1] [2]Rowobjects. [1] [2] [3]C++/pybind11 Python type caching
PythonObjectCachenamespace inddbc_bindings.cppto cache references to Python classes (datetime,date,time,decimal,uuid). This reduces overhead and avoids issues during Python finalization. All type checks and conversions now use the cached objects. [1] [2] [3] [4] [5] [6] [7]Cursor configuration and resource management
__exit__in the PythonCursorclass consistently returnsNonefor proper context manager behavior.Miscellaneous improvements
executemethod, ensuring column metadata is properly described and available for optimizations.