pyston / pyston_v1

The previous version of Pyston, a faster implementation of the Python programming language. Please use this link for the new repository:
https://github.com/pyston/pyston/
4.89k stars 290 forks source link

__eq__ overload not working #253

Closed ghost closed 9 years ago

ghost commented 9 years ago

If I have the following code:

class A:
    def __eq__(self, other):
        return True

a0 = A()
a1 = A()
print a0 == a1

Pyston will print False while CPython will print True, why?

tjhance commented 9 years ago

If you're asking why Pyston behaves differently from CPython, the answer is almost always "bug or unimplemented feature" :)

Right now Pyston's support for "old-style classes" is pretty lacking. If you make it a "new-style class" (by deriving it from object), it works:

class A(object):                                                                                                                                                                                                                                                              
    def __eq__(self, other):
        return True

a0 = A() 
a1 = A() 
print a0 == a1

But as you point out we need to make it work for old-style classes too. For this we need to implement the __eq__ method on instance objects (src/runtime/classobj.cpp).

kmod commented 9 years ago

Ok I opened #254 to track this and the other missing ones, thanks for bringing it up!