private bool ValueEqualsPythonDict(PythonDictionary pd, IEqualityComparer comparer) { List myKeys = keys(); foreach (object o in myKeys) { object res; if (!pd.TryGetValueNoMissing(o, out res)) { return(false); } CompareUtil.Push(res); try { if (comparer == null) { if (!PythonOps.EqualRetBool(res, this[o])) { return(false); } } else { if (!comparer.Equals(res, this[o])) { return(false); } } } finally { CompareUtil.Pop(res); } } return(true); }
public static object get(PythonDictionary self, object key, object defaultValue = null) { if (self.TryGetValueNoMissing(key, out object ret)) { return(ret); } return(defaultValue); }
public static object setdefault(PythonDictionary self, object key, object defaultValue) { if (self.TryGetValueNoMissing(key, out object ret)) { return(ret); } self.SetItem(key, defaultValue); return(defaultValue); }
public static object setdefault(PythonDictionary self, object key, object defaultValue) { object ret; if (self.TryGetValueNoMissing(key, out ret)) { return(ret); } self[key] = defaultValue; return(defaultValue); }
public static object pop(PythonDictionary self, object key) { //??? perf won't match expected Python perf if (self.TryGetValueNoMissing(key, out object ret)) { self.RemoveDirect(key); return(ret); } else { throw PythonOps.KeyError(key); } }
public static object pop(PythonDictionary self, object key, object defaultValue) { //??? perf won't match expected Python perf object ret; if (self.TryGetValueNoMissing(key, out ret)) { self.RemoveDirect(key); return(ret); } else { return(defaultValue); } }