예제 #1
0
    def __eq__(self, other):
        """ Two Primitives are equal iff their all their properties are equal.
        Consider bound and unbound methods equal. """
        # other is a Primitive
        if isinstance(other, Primitive):
            return (self == other.func and
                    self.return_type == other.return_type and
                    self.arg_descs == other.arg_descs and
                    self.kwarg_descs == other.kwarg_descs and
                    self.call_afterwards == other.call_afterwards and
                    self.export_me == other.export_me)

        # other is a callable
        elif callable(other):
            if is_instancemethod(self.func) != is_instancemethod(other):
                return False
            elif is_instancemethod(self.func):  # and is_instancemethod(other):
                return (self.func.im_class == other.im_class and
                        self.func.im_func == other.im_func)
            else:
                return self.func == other

        elif is_staticmethod(other):
            return self.func == other.__func__

        # other is neither a Primitive nor a callable
        else:
            return False
    def __eq__(self, other):
        """ Two Primitives are equal iff their all their properties are equal.
        Consider bound and unbound methods equal. """
        # other is a Primitive
        if isinstance(other, Primitive):
            return (self == other.func and
                    self.return_type == other.return_type and
                    self.arg_descs == other.arg_descs and
                    self.kwarg_descs == other.kwarg_descs and
                    self.call_afterwards == other.call_afterwards and
                    self.export_me == other.export_me)

        # other is a callable
        elif callable(other):
            if is_instancemethod(self.func) != is_instancemethod(other):
                return False
            elif is_instancemethod(self.func):  # and is_instancemethod(other):
                return (self.func.im_class == other.im_class and
                        self.func.im_func == other.im_func)
            else:
                return self.func == other

        elif is_staticmethod(other):
            return self.func == other.__func__

        # other is neither a Primitive nor a callable
        else:
            return False