Add more list functions to the c-api#8045
Conversation
📝 WalkthroughWalkthroughThis PR extends RustPython's CPython compatibility layer by adding four new list C-API functions: ChangesList C-API Extensions
Sequence Diagram(s)No sequence diagram generated. This PR introduces FFI function implementations within a single module without multi-component sequential flows that would benefit from visualization. Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
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 |
Sorry, something went wrong.
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/listobject.rs`:
- Around line 160-164: PyList_Sort currently downcasts to PyList and uses
vm.call_method(list.as_object(), "sort", ()) which performs normal Python-level
dispatch and can run overridden user code; change it to invoke the builtin list
sort implementation directly (not via instance dispatch). Specifically, replace
vm.call_method(...) in PyList_Sort with a direct call to the internal list
sorting routine (the in-place sorter for PyList) or call the "sort" function
bound to the exact built-in list type rather than the instance (e.g., resolve
the attribute on vm.ctx.types.list_type and invoke that bound function with the
list as self, or call PyList's internal sort method such as the library's
sort_inplace routine), ensuring no instance-level __dict__/subclass override can
run. Use the symbols PyList_Sort, PyList, and avoid vm.call_method to implement
this change.
🪄 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: 5c374d9b-913d-4252-8864-62b444550774
📒 Files selected for processing (1)
crates/capi/src/listobject.rs
Sorry, something went wrong.
19ca508
into
RustPython:main
Jun 10, 2026
Summary by CodeRabbit
New Features
Tests