__str__ with slot wrapper, generate slot with #[pymethod] by youknowone · Pull Request #6485 · RustPython/RustPython
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.