'Equality test for polynomials.
Examples
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring
>>> _, x, y = ring(\'x, y\', ZZ)
>>> p1 = (x + y)**2 + (x - y)**2
>>> p1 == 4*x*y
False
>>> p1 == 2*(x**2 + y**2)
True'

def __eq__(p1, p2):

    if (not p2):
        return (not p1)
    elif (isinstance(p2, PolyElement) and (p2.ring == p1.ring)):
        return dict.__eq__(p1, p2)
    elif (len(p1) > 1):
        return False
    else:
        return (p1.get(p1.ring.zero_monom) == p2)
