@@ -2,9 +2,9 @@ use super::{PyDict, PyDictRef, PyGenericAlias, PyList, PyTuple, PyType, PyTypeRe
22use crate :: {
33 class:: PyClassImpl ,
44 convert:: ToPyObject ,
5- function:: { ArgMapping , OptionalArg } ,
5+ function:: { ArgMapping , OptionalArg , PyComparisonValue } ,
66 protocol:: { PyMapping , PyMappingMethods , PyNumberMethods , PySequence , PySequenceMethods } ,
7- types:: { AsMapping , AsNumber , AsSequence , Constructor , Iterable } ,
7+ types:: { AsMapping , AsNumber , AsSequence , Comparable , Constructor , Iterable , PyComparisonOp } ,
88 AsObject , Context , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyResult , VirtualMachine ,
99} ;
1010
@@ -64,7 +64,7 @@ impl Constructor for PyMappingProxy {
6464 }
6565}
6666
67- #[ pyimpl( with( AsMapping , Iterable , Constructor , AsSequence ) ) ]
67+ #[ pyimpl( with( AsMapping , Iterable , Constructor , AsSequence , Comparable ) ) ]
6868impl PyMappingProxy {
6969 fn get_inner ( & self , key : PyObjectRef , vm : & VirtualMachine ) -> PyResult < Option < PyObjectRef > > {
7070 let opt = match & self . mapping {
@@ -185,6 +185,20 @@ impl PyMappingProxy {
185185 }
186186}
187187
188+ impl Comparable for PyMappingProxy {
189+ fn cmp (
190+ zelf : & crate :: Py < Self > ,
191+ other : & PyObject ,
192+ op : PyComparisonOp ,
193+ vm : & VirtualMachine ,
194+ ) -> PyResult < PyComparisonValue > {
195+ let obj = zelf. to_object ( vm) ?;
196+ Ok ( PyComparisonValue :: Implemented (
197+ obj. rich_compare_bool ( other, op, vm) ?,
198+ ) )
199+ }
200+ }
201+
188202impl AsMapping for PyMappingProxy {
189203 const AS_MAPPING : PyMappingMethods = PyMappingMethods {
190204 length : Some ( |mapping, vm| Self :: mapping_downcast ( mapping) . len ( vm) ) ,
0 commit comments