[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/jsliugang/pythonnet/master/src/runtime/PythonReferenceComparer.cs [Back]  [Original]

#nullable enable
using System.Collections.Generic;

namespace Python.Runtime
{
    /// 
    /// Compares Python object wrappers by Python object references.
    /// Similar to  but for Python objects
    /// 
    public sealed class PythonReferenceComparer : IEqualityComparer
    {
        public static PythonReferenceComparer Instance { get; } = new PythonReferenceComparer();
        public bool Equals(PyObject? x, PyObject? y)
        {
            return x?.Handle == y?.Handle;
        }

        public int GetHashCode(PyObject obj) => obj.Handle.GetHashCode();

        private PythonReferenceComparer() { }
    }
}

Web Proxy Viewer  |  New URL  |  Original Page