Skip to content

Avoid eager NumPy checks for prepared parameters#23

Merged
adsharma merged 1 commit into
mainfrom
numpy_optional
May 30, 2026
Merged

Avoid eager NumPy checks for prepared parameters#23
adsharma merged 1 commit into
mainfrom
numpy_optional

Conversation

@adsharma
Copy link
Copy Markdown
Contributor

Summary

  • Avoid pybind NumPy array checks for non-NumPy prepared statement parameters
  • Avoid importing NumPy in the C-API fallback unless the value type is from NumPy
  • Keep ndarray parameter support intact for users that do have NumPy installed

Root Cause

The ndarray support added NumPy-specific isinstance checks to the prepared parameter path. In pybind, checking against py::array can initialize NumPy even for ordinary Python parameters.

Validation

  • uvx ruff check src_py/_lbug_capi.py
  • PYTHONPATH=./build .venv/bin/pytest test/test_prepared_statement.py test/test_issue.py::test_issue_483_numpy_ndarray_parameter -q
  • Fresh pybind smoke test with numpy imports blocked via sys.meta_path while executing a scalar prepared statement

@adsharma adsharma marked this pull request as ready for review May 30, 2026 14:42
@adsharma adsharma merged commit 902efae into main May 30, 2026
2 checks passed
@adsharma adsharma deleted the numpy_optional branch May 30, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant