pyo3/guide
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
..
src Merge #3203 2023-06-05 07:13:23 +00:00
book.toml Add git repository and edit urls to user guide (#2635) 2022-09-23 00:56:25 +00:00
pyclass_parameters.md Add PyClass::get and Py::get for GIL-independent access to frozen classes. 2023-05-18 08:57:55 +02:00
pyo3_version.py release: 0.17.2 2022-10-04 08:13:53 +01:00