mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
update compare method
This commit is contained in:
1 parent
2da623eadf
commit
79eae0d5fe
1 file changed
+6
-9
@@ -2,7 +2,6 @@ use super::{
|
||||
set::PySetInner, IterStatus, PositionIterInternal, PyBaseExceptionRef, PyGenericAlias, PySet,
|
||||
PyStrRef, PyTupleRef, PyType, PyTypeRef,
|
||||
};
|
||||
use crate::sequence::ObjectSequenceOp;
|
||||
use crate::{
|
||||
builtins::{
|
||||
iter::{builtins_iter, builtins_reversed},
|
||||
@@ -16,6 +15,7 @@ use crate::{
|
||||
function::{
|
||||
ArgIterable, FuncArgs, KwArgs, OptionalArg, PyArithmeticValue::*, PyComparisonValue,
|
||||
},
|
||||
iter::PyExactSizeIterator,
|
||||
protocol::{PyIterIter, PyIterReturn, PyMappingMethods, PySequenceMethods},
|
||||
recursion::ReprGuard,
|
||||
types::{
|
||||
@@ -1018,14 +1018,11 @@ trait ViewSetOps: DictView {
|
||||
return Ok(NotImplemented);
|
||||
}
|
||||
});
|
||||
let self_vec: Vec<PyObjectRef> = zelf.as_object().to_owned().try_into_value(vm)?;
|
||||
let other_vec: Vec<PyObjectRef> = other.to_owned().try_into_value(vm)?;
|
||||
let res = self_vec.eq(vm, &other_vec)?;
|
||||
match op {
|
||||
PyComparisonOp::Eq => Ok(Implemented(res)),
|
||||
PyComparisonOp::Ne => Ok(Implemented(!res)),
|
||||
_ => Ok(NotImplemented),
|
||||
}
|
||||
let lhs: Vec<PyObjectRef> = zelf.as_object().to_owned().try_into_value(vm)?;
|
||||
let rhs: Vec<PyObjectRef> = other.to_owned().try_into_value(vm)?;
|
||||
lhs.iter()
|
||||
.richcompare(rhs.iter(), op, vm)
|
||||
.map(PyComparisonValue::Implemented)
|
||||
}
|
||||
|
||||
#[pymethod]
|
||||
|
||||
Reference in new issue
Block a user