Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary equality comparison differs from CPython #757

Open
JennaSys opened this issue Sep 9, 2020 · 2 comments
Open

Dictionary equality comparison differs from CPython #757

JennaSys opened this issue Sep 9, 2020 · 2 comments

Comments

@JennaSys
Copy link
Collaborator

JennaSys commented Sep 9, 2020

I'm not sure if this a known difference with CPython, but when comparing dictionaries for equality, the transpiled JS always returns false. I assume this has to do with how JavaScript compares objects in general. For example:

Python Code:

def dict_test():
    x = {'a': 12, 'c': 99, 'b': 54}
    y = {'a': 12, 'b': 54, 'c': 99}
    print(x == y)

# returns True

Transcrypted Code:

export var dict_test = function () {
    var x = dict({"a": 12, "c": 99, "b": 54});
    var y = dict({"a": 12, "c": 99, "b": 54});
    print(x == y)
};

// returns false

I'm assuming the only solution would be to do a recursive comparison of values, or use a 3rd party library like Lodash's _.isEqual() function.

@faerot
Copy link

faerot commented Oct 5, 2020

There is no dict comparison code in Transcrypt, I have already reported it in: #721

@JdeH
Copy link
Collaborator

JdeH commented Nov 2, 2020

It is not a known difference but an omission.
Will classify it as enhancement with #721
Thanks!

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

No branches or pull requests

3 participants