__str__ with slot wrapper, generate slot with #[pymethod]#6485
__str__ with slot wrapper, generate slot with #[pymethod]#6485youknowone wants to merge 1 commit intoRustPython:mainfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ 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 |
05933fe to
d4a2177
Compare
Here are my concerns:
|
No, this is a sort of developer interface. CPython test suites test the implementation. It doesn't matter if we use a trait or fake pymethod.
Because this form is an alternative form of the trait approach, which is already implmemented for |
ShaharNaveh
left a comment
There was a problem hiding this comment.
All concerns addressed at #6485 (comment)
Not sure this is a good idea or not.
Motivation: we have too many fragmented traits, which are easy to forget to add in
with()attrs.Now
__str__will more looking like a normal #[pymethod]. But what it backs will be very different. It actually doesn't create a real pymethod, but actually creating slot_str. And__str__will be placed by a slot-wrapper descriptor.After the patch,
#[pymethod] fn __str__will additionally create a pyslot for str.This can be applicable to other single-method traits too.
Pros: Easy to understand. No worry to forget to add
with()Cons: Confusing because it have different semantics comparing to other real pymethods.