Skip to content

Commit e2cd6ef

Browse files
committed
py: __eq__ and __ne__ for type
1 parent 07d321a commit e2cd6ef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

py/type.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,22 @@ func ObjectNew(t *Type, args Tuple, kwargs StringDict) Object {
16061606
return t.Alloc()
16071607
}
16081608

1609+
// FIXME this should be the default?
1610+
func (ty *Type) M__eq__(other Object) Object {
1611+
if otherTy, ok := other.(*Type); ok && ty == otherTy {
1612+
return True
1613+
}
1614+
return False
1615+
}
1616+
1617+
// FIXME this should be the default?
1618+
func (ty *Type) M__ne__(other Object) Object {
1619+
if otherTy, ok := other.(*Type); ok && ty == otherTy {
1620+
return False
1621+
}
1622+
return True
1623+
}
1624+
16091625
// Make sure it satisfies the interface
16101626
var _ Object = (*Type)(nil)
16111627
var _ I__call__ = (*Type)(nil)

0 commit comments

Comments
 (0)