@@ -157,16 +157,20 @@ impl PyDict {
157157 item : bool ,
158158 vm : & VirtualMachine ,
159159 ) -> PyResult < PyComparisonValue > {
160+ if op == PyComparisonOp :: Ne {
161+ return Self :: inner_cmp ( zelf, other, PyComparisonOp :: Eq , item, vm)
162+ . map ( |x| x. map ( |eq| !eq) ) ;
163+ }
160164 if !op. eval_ord ( zelf. len ( ) . cmp ( & other. len ( ) ) ) {
161165 return Ok ( Implemented ( false ) ) ;
162166 }
163- let ( zelf , other ) = if zelf. len ( ) < other. len ( ) {
167+ let ( superset , subset ) = if zelf. len ( ) < other. len ( ) {
164168 ( other, zelf)
165169 } else {
166170 ( zelf, other)
167171 } ;
168- for ( k, v1) in other {
169- match zelf . get_item_option ( k, vm) ? {
172+ for ( k, v1) in subset {
173+ match superset . get_item_option ( k, vm) ? {
170174 Some ( v2) => {
171175 if v1. is ( & v2) {
172176 continue ;
@@ -421,11 +425,8 @@ impl Comparable for PyDict {
421425 vm : & VirtualMachine ,
422426 ) -> PyResult < PyComparisonValue > {
423427 op. eq_only ( || {
424- if let Ok ( other) = other. downcast :: < PyDict > ( ) {
425- Self :: inner_cmp ( zelf, other, PyComparisonOp :: Eq , true , vm)
426- } else {
427- Ok ( PyComparisonValue :: NotImplemented )
428- }
428+ let other = class_or_notimplemented ! ( Self , other) ;
429+ Self :: inner_cmp ( zelf, other, PyComparisonOp :: Eq , true , vm)
429430 } )
430431 }
431432}
0 commit comments