What is the best way to compare two objects within a PyIterator
(PyAny
)
#2502
-
Hello all, I have a handful of existing functions that require I am thinking that two options are either to try to downcast into various python types that might be comparable, or to implement |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You probably want to wrap your Some brief history - |
Beta Was this translation helpful? Give feedback.
You probably want to wrap your
PyAny
objects in a newtype which does exactly this, or alternatively could returnNone
fromPartialEq::cmp
if there's an exception raised during comparison. For now we're undecided what the correct error handling strategy is if PyO3 were to provide aPartialEq
implementation.Some brief history -
PyAny
used to implementPartialEq
using pointer comparison (i.e. Pythonis
), which was almost certainly a footgun. We removed that implementation a couple of versions ago, and now in a cooling off period to take stock before we consider if we add a more correct implementation back.