| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
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: 7fd75980-450b-49a4-8956-751405d32969 📥 CommitsReviewing files that changed from the base of the PR and between 69d97b0 and f884722. 📒 Files selected for processing (11)
📝 Walkthrough WalkthroughNewFunc changes from a function-pointer alias to an enum with identity and invocation methods. Generated constructors store typed Rust variants, while built-in and type dispatch paths use .invoke() and identity-based comparisons. ChangesNew slot dispatch
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant BuiltinVectorcall
participant NewFunc
participant TypeDispatch
BuiltinVectorcall->>NewFunc: Load slots.new and invoke(cls, args, vm)
TypeDispatch->>NewFunc: Invoke resolved __new__ slot
NewFunc-->>BuiltinVectorcall: Return PyResult
❌ Failed checks (1 warning)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)crates/vm/src/types/slot.rs (1)🤖 Prompt for all review comments with AI agents316-329: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Derive PartialEq, Eq to simplify identity checks.
Function pointers natively implement PartialEq and Eq. Deriving these traits on NewFunc allows direct equality comparisons (== and !=) on the variants, entirely eliminating the need for the manual identity() method and the verbose mapping at all call sites.
🤖 Prompt for AI Agents
- crates/vm/src/types/slot.rs#L316-L329: Add #[derive(PartialEq, Eq)] to NewFunc and remove the identity method entirely.
- crates/vm/src/types/slot.rs#L909-L911: Replace the comparison with cls.slots.new.load() == Some(NewFunc::Rust(new_wrapper as _)).
- crates/vm/src/builtins/type.rs#L2835-L2835: Replace the condition with slot_new != crate::types::NewFunc::Rust(crate::types::new_wrapper as _).
- crates/vm/src/builtins/type.rs#L3072-L3072: Replace the check with if typ_new != staticbase_new {.
- crates/vm/src/class.rs#L207-L208: Replace the inheritance check with !is_object_itself && object_new == Some(slot_new).
- crates/vm/src/frame.rs#L9243-L9243: Replace the identity comparison with cls_new_fn == obj_new_fn.
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/vm/src/types/slot.rs` around lines 316 - 329, Derive PartialEq and Eq for NewFunc and remove its identity method, then replace all identity-based comparisons with direct NewFunc equality checks: update crates/vm/src/types/slot.rs lines 316-329 and 909-911, crates/vm/src/builtins/type.rs lines 2835 and 3072, crates/vm/src/class.rs lines 207-208, and crates/vm/src/frame.rs line 9243 as specified, preserving the existing comparison semantics.
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/vm/src/types/slot.rs`: - Around line 316-320: Preserve lock-free access for PyTypeSlots::new by avoiding the two-variant NewFunc representation in AtomicCell<Option<NewFunc>>. Update NewFunc and the associated new-slot storage/access paths to use a pointer-sized representation compatible with the target atomic width, while retaining support for both Rust and C constructors. --- Nitpick comments: In `@crates/vm/src/types/slot.rs`: - Around line 316-329: Derive PartialEq and Eq for NewFunc and remove its identity method, then replace all identity-based comparisons with direct NewFunc equality checks: update crates/vm/src/types/slot.rs lines 316-329 and 909-911, crates/vm/src/builtins/type.rs lines 2835 and 3072, crates/vm/src/class.rs lines 207-208, and crates/vm/src/frame.rs line 9243 as specified, preserving the existing comparison semantics.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: b97f0fc2-eccf-40ed-878e-0572a321a7a8
📥 CommitsReviewing files that changed from the base of the PR and between cc30cd5 and 00b1ca8.
📒 Files selected for processing (11)
Sorry, something went wrong.
| Rust(fn(PyTypeRef, FuncArgs, &VirtualMachine) -> PyResult), | ||
| C(unsafe extern "C" fn(*mut PyObject, *mut PyObject, *mut PyObject) -> *mut PyObject), |
There was a problem hiding this comment.
I'd like not to introduce an enum for this.
let me try do this by adding a bridge in capi side.
Sorry, something went wrong.
There was a problem hiding this comment.
We might need a Box<dyn Fn> for this. As in my testing I could not store ar c fn in a fn slot.
Sorry, something went wrong.
There was a problem hiding this comment.
If you need a testbed, please try to fix this TODO here: https://github.com/bschoenmaeckers/RustPython/blob/880999db85bd14f497e48e07e74b3745dd484994/crates/capi/src/object/pytype.rs#L194-L198
Sorry, something went wrong.
There was a problem hiding this comment.
this is more complicated than my first expectation. i am trying another way
Sorry, something went wrong.
There was a problem hiding this comment.
could you check if this way work? #8435
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is my first draft of allowing C functions in type slots. I started with the NewFunc slot and would love some feedback on my approach before converting the other slots.
@youknowone Could you please share your opinion.
Summary by CodeRabbit
Bug Fixes
Compatibility