diff --git a/vm/src/builtins/object.rs b/vm/src/builtins/object.rs index 91fab95b7b..fa8a88682a 100644 --- a/vm/src/builtins/object.rs +++ b/vm/src/builtins/object.rs @@ -40,7 +40,7 @@ impl PyBaseObject { } #[pyslot] - fn tp_cmp( + fn tp_richcompare( zelf: &PyObjectRef, other: &PyObjectRef, op: PyComparisonOp, @@ -67,7 +67,7 @@ impl PyBaseObject { PyComparisonOp::Ne => { let cmp = zelf .class() - .mro_find_map(|cls| cls.slots.cmp.load()) + .mro_find_map(|cls| cls.slots.richcompare.load()) .unwrap(); let value = match cmp(zelf, other, PyComparisonOp::Eq, vm)? { Either::A(obj) => PyArithmaticValue::from_object(vm, obj) diff --git a/vm/src/builtins/pytype.rs b/vm/src/builtins/pytype.rs index 11f412c22d..48c1b9c2e4 100644 --- a/vm/src/builtins/pytype.rs +++ b/vm/src/builtins/pytype.rs @@ -193,11 +193,11 @@ impl PyType { update_slot!(del, func); } "__eq__" | "__ne__" | "__le__" | "__lt__" | "__ge__" | "__gt__" => { - let func: slots::CmpFunc = |zelf, other, op, vm| { + let func: slots::RichCompareFunc = |zelf, other, op, vm| { vm.call_special_method(zelf.clone(), op.method_name(), (other.clone(),)) .map(Either::A) } as _; - update_slot!(cmp, func); + update_slot!(richcompare, func); } "__getattribute__" => { let func: slots::GetattroFunc = diff --git a/vm/src/slots.rs b/vm/src/slots.rs index 46279d506f..b8b67a0d75 100644 --- a/vm/src/slots.rs +++ b/vm/src/slots.rs @@ -52,7 +52,7 @@ pub(crate) type DescrGetFunc = pub(crate) type DescrSetFunc = fn(PyObjectRef, PyObjectRef, Option, &VirtualMachine) -> PyResult<()>; pub(crate) type HashFunc = fn(&PyObjectRef, &VirtualMachine) -> PyResult; -pub(crate) type CmpFunc = fn( +pub(crate) type RichCompareFunc = fn( &PyObjectRef, &PyObjectRef, PyComparisonOp, @@ -89,7 +89,7 @@ pub struct PyTypeSlots { // Assigned meaning in release 2.1 // rich comparisons - pub cmp: AtomicCell>, + pub richcompare: AtomicCell>, // Iterators pub iter: AtomicCell>, @@ -268,7 +268,7 @@ where #[pyimpl] pub trait Comparable: PyValue { #[pyslot] - fn tp_cmp( + fn tp_richcompare( zelf: &PyObjectRef, other: &PyObjectRef, op: PyComparisonOp, diff --git a/vm/src/vm.rs b/vm/src/vm.rs index e4ccf5280f..0c74e3186c 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -1654,7 +1654,7 @@ impl VirtualMachine { let call_cmp = |obj: &PyObjectRef, other, op| { let cmp = obj .class() - .mro_find_map(|cls| cls.slots.cmp.load()) + .mro_find_map(|cls| cls.slots.richcompare.load()) .unwrap(); Ok(match cmp(obj, other, op, self)? { Either::A(obj) => PyArithmaticValue::from_object(self, obj).map(Either::A),