def is_gaussian_integer(z):
    """
        Checks whether a given real or complex number is a Gaussian integer,
        i.e. a complex number g = a + bi such that a and b are integers.
    """
    if type(z) == int:
        return True
    return z.real.is_integer() and z.imag.is_integer()