Add iter support to c-api#8035
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds an iter submodule re-export and C-ABI FFI bindings for iterator operations (check, get-iter, next-item, next, send) plus a new PyObject_Size function that returns an object's length via obj.length(vm). ChangesIterator and Object Measurement C API Extension
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
84b2e08 to
39772a7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/capi/src/abstract_/iter.rs`:
- Around line 65-68: In PyIter_Send, change the current hard downcast to
PyGenerator so it matches CPython: first check if arg_obj.is_none(); if so,
attempt to downcast iter_obj to PyGenerator and call as_coro().send(...) when it
is a generator, but if it's not a generator call PyIter::new(iter_obj).next(vm)
to advance the iterator; if arg_obj is not None and iter_obj is not a
PyGenerator, raise a TypeError. Use the existing methods
try_downcast_ref::<PyGenerator>, PyGenerator::as_coro().send, and
PyIter::new(iter_obj).next(vm) to implement the fallback.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 6cd14683-2403-4826-83dd-15a54a1a8120
📒 Files selected for processing (2)
crates/capi/src/abstract_.rscrates/capi/src/abstract_/iter.rs
39772a7 to
21fffc5
Compare
Summary by CodeRabbit