- Notifications
You must be signed in to change notification settings - Fork757
-
When working with value objects converted from pybind11, some objects override the equality operator (==). In such cases, I need to compare objects based on reference equality instead of value equality. In Python, this is typically done using id(obj) or the is operator to check if two variables point to the same object . In pythonnet, I attempted to use PyObject.Handle for this purpose, but it is marked as obsolete . What is the recommended way to achieve reference equality comparisons in pythonnet now? For example:
|
BetaWas this translation helpful?Give feedback.
All reactions
There's aPythonReferenceComparer.Instance
of typeIEqualityComparer<PyObject>
Replies: 1 comment 1 reply
-
There's a |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thx,i replaced it with this method and it's working. |
BetaWas this translation helpful?Give feedback.
All reactions
This discussion was converted from issue #2603 on July 16, 2025 20:46.