For types that implement PartialEq/Eq, Python's __richcmp__ dunder method is easily defined as:
#[pymethods]
impl PyType {
pub fn __richcmp__(&self, py: Python<'_>, other: &Self, op: CompareOp) -> PyObject {
match op {
CompareOp::Eq => (self.as_inner() == other.as_inner()).into_py(py),
_ => py.NotImplemented(),
}
}
}
An impl_eq! macro would be a nice addition to handle this case. The overlap with impl_compare! would have to be well documented to avoid confusion.