Comparison of lists with objects not working? #2

Open
pyjsorg opened this Issue Apr 27, 2012 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

pyjsorg commented Apr 27, 2012

> What steps will reproduce the problem?

The following code runs fine in Python, but asserts in Firefox 11.0 when compiled with pyjs.

class C:
def init(self, value):
self.value = value

def __eq__(self, other):
    return self.value == other.value

assert [1, 2, 3] == [1, 2, 3] # OK
assert [C(1), C(2), C(3)] == [C(1), C(2), C(3)] # fails

>>> What version of Pyjamas are you using? which svn revision number?
On what operating system?

I'm using pyjamas-0.8.1~+alpha1 (same with older versions) on Mac OS X 10.6.

>>> If using PyJS, what compiler options did you use?
-d

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=721 (April 22, 2012 21:36:04)

Contributor

pyjsorg commented Apr 29, 2012

From luke.lei...@gmail.com on April 28, 2012 02:12:29:
this looks like a good test. can you please create a patch to LibTest and reference bug #721 in the assertTrue message?

also double-check that you're using --strict: the performance penalty for emulating certain features of python in javascript are so high that they need to be enabled only when you really need them.

thanks frank.

sfxxx commented May 25, 2012

Here's a more readable version of the code. It got messed up by the markup syntax on import. And yes, I was using --strict.

class C:
  def init(self, value):
    self.value = value
  def __eq__(self, other):
    return self.value == other.value

assert [1, 2, 3] == [1, 2, 3] # OK
assert [C(1), C(2), C(3)] == [C(1), C(2), C(3)] # fails
Member

anthonyrisinger commented May 26, 2012

nice :-)

i'm about to call it a night and didn't check myself ... was this ever added to libtest? if you could please send a pull req with it's inclusion that would be 100% fantastic, else i will add it sometime soon. i'll take a look at the generated code of your example and see if anything jumps out ... btw, does:

C(1) == C(1)

... work as expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment