if isinstance(a, np.ndarray):
    return np.all(a == b)
if isinstance(a, Sequence):
    return all(nested_equal(x, y) for x, y in zip(a, b))
if isinstance(a, Mapping):
    if set(a.keys()) != set(b.keys()):
        return False
return all(nested_equal(a[k], b[k]) for k in list(a.keys()))
if isinstance(a, Set):
    return a == b
return a == b
Лучшие практики для равенства в Python