ea9708092e
Two things are handled here: allow to compare native subtypes of tuple, e.g. namedtuple (TODO: should compare type too, currently compared duck-typedly by content). Secondly, allow user sunclasses of tuples (and its subtypes) be compared either. "Magic" I did previously in objtype.c covers only one argument (lhs is many), so we're in trouble when lhs is native type - there's no other option besides handling rhs in special manner. Fortunately, this patch outlines approach with fast path for native types.
10 lines
170 B
Python
10 lines
170 B
Python
# Test calling non-special method inherited from native type
|
|
|
|
class mytuple(tuple):
|
|
pass
|
|
|
|
t = mytuple((1, 2, 3))
|
|
print(t)
|
|
print(t == (1, 2, 3))
|
|
print((1, 2, 3) == t)
|