public static bool _compare_digest(object a, object b) { var aStr = a as string ?? (a as Extensible <string>)?.Value; var bStr = b as string ?? (b as Extensible <string>)?.Value; if (aStr != null && bStr != null) { if (!StringOps.TryEncodeAscii(aStr, out Bytes aBytes) || !StringOps.TryEncodeAscii(bStr, out Bytes bBytes)) { throw PythonOps.TypeError("comparing strings with non-ASCII characters is not supported"); } return(CompareBytes(aBytes, bBytes)); } else if (a is IBufferProtocol abp && b is IBufferProtocol bbp) { using IPythonBuffer aBuf = abp.GetBuffer(); using IPythonBuffer bBuf = bbp.GetBuffer(); if (aBuf.NumOfDims > 1 || bBuf.NumOfDims > 1) { throw PythonOps.BufferError("Buffer must be single dimension"); } return(CompareBytes(aBuf.AsReadOnlySpan().ToArray(), bBuf.AsReadOnlySpan().ToArray())); } throw PythonOps.TypeError("unsupported operand types(s) or combination of types: '{0}' and '{1}'", PythonOps.GetPythonTypeName(a), PythonOps.GetPythonTypeName(b)); }