pyo3/newsfragments
bors[bot] dbf7b233aa
Merge #3203
3203: support ordering magic methods for `#[pyclass]` r=adamreichold a=davidhewitt

Closes #2089 

This adds `__lt__`, `__le__`, `__eq__`, `__ne__`, `__gt__`, and `__ge__` as per the Python implementations of what we call `__richcmp__`.

There's a UI test confirming that the user cannot implement split forms and `__richcmp__` simultaneously.

There's also a benchmark comparing implementing these split methods against using `__richcmp__`. I couldn't see a meaningful performance difference, so I'm tempted to deprecate `__richcmp__`, given that's not a magic method which exists in Python. Potentially we can provide options such as the opt-in `#[pyclass(eq, ord)]` to avoid boilerplate for people who don't want to implement six different methods.



Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-06-05 07:13:23 +00:00
..
.gitignore use towncrier to generate CHANGELOG 2022-09-08 07:58:53 +01:00
3185.fixed.md Fix abi3 conversion of __complex__ classes 2023-06-02 10:09:45 +01:00
3198.added.md Add abi3 + num_bigint conversion 2023-06-02 16:17:49 +09:00
3203.added.md support ordering magic methods for #[pyclass] 2023-06-04 13:58:18 +01:00
3208.packaging.md Bump MSRV to 1.56 2023-06-04 23:02:30 +01:00