[codex] fix python id coercion review follow-ups#92
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes the handling of non-contiguous uint32 arrays in as_u32_ids_1d by copying them directly within the fast-path check, avoiding the fallback macro path. Feedback suggests using .to_vec() on the ndarray view instead of manually iterating and collecting, which is more idiomatic and efficient.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
3f51fd3 to
df08e99
Compare
Review Summary by QodoHandle non-contiguous uint32 arrays in id coercion fast path
WalkthroughsDescription• Clarify FFI boundary docs: candidate/doc-id arrays support non-contiguous layouts • Handle non-contiguous uint32 arrays directly in fast path via copying • Remove redundant try_int_dtype!(u32) macro invocation and simplify comments Diagramflowchart LR
A["Non-contiguous uint32 array"] -->|"Previously fell through"| B["Generic checked conversion"]
A -->|"Now handled directly"| C["Copy via iterator"]
C --> D["CandidateIds::Owned"]
E["Contiguous uint32 array"] -->|"Zero-copy borrow"| F["CandidateIds::Borrowed"]
G["Other integer dtypes"] -->|"Checked conversion"| D
File Changes1. ordvec-python/src/lib.rs
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
Follow-up to prior Python FFI boundary work for candidate/doc-id inputs: aligns the crate-level docs with the intended “non-contiguous IDs are allowed (via copy)” exception, and optimizes the uint32 fast-path to avoid redundant checked conversions for non-contiguous uint32 arrays.
Changes:
- Clarify module-level FFI boundary documentation to call out candidate/doc-id non-contiguous handling as an exception.
- Improve
as_u32_ids_1dfast-path to directly copy non-contiguousuint32inputs (while still zero-copy borrowing contiguousuint32). - Simplify the dtype matching order/comments by removing the redundant
try_int_dtype!(u32)path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
|
Bot review disposition for top-level findings:
Validation:
|
Summary
Follow up on outstanding PR #90 bot review findings after #90/#91 were merged:
uint32candidate/doc-id arrays directly in theas_u32_ids_1dfast path by copying them, instead of falling through to the generic checked conversion macrotry_int_dtype!(u32)path and simplify the dtype-order commentWhy
PR #90 changed candidate/doc-id inputs from strict
uint32to checked integer coercion. Two bot findings were still valid after the combined merge:uint32helper path could handle both contiguous and non-contiguous arrays without a redundant cast/conversion pass.The Qodo range-string spacing finding was investigated separately and not changed: Rust string continuations do not preserve the newline indentation in the emitted message.
Validation
cargo fmt -p ordvec-python --checkcargo clippy -p ordvec-python --all-targets -- -D warningsmaturin develop.venv/bin/pytest tests/test_input_guards.py