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

Need to implement __hash__ so entities work with sets #1

Open
six8 opened this issue May 1, 2015 · 4 comments
Open

Need to implement __hash__ so entities work with sets #1

six8 opened this issue May 1, 2015 · 4 comments

Comments

@six8
Copy link
Collaborator

six8 commented May 1, 2015

No description provided.

@BatsShadow
Copy link
Contributor

This is fixed in #25, right?

@six8
Copy link
Collaborator Author

six8 commented May 8, 2019

I suppose so. But we may need to decide on what to __hash__ on. #25 uses id(self) which will use the object's instance ID as a hash. So even if two entity instances have the exact same values, they'll be consider different because they are different instances. If two entity instances with the exact same values should be considered a duplicate, then the __hash__ should take into account the values of the entity.

@BatsShadow
Copy link
Contributor

BatsShadow commented May 8, 2019 via email

@six8
Copy link
Collaborator Author

six8 commented May 8, 2019

In Python 2 the default __hash__ is basically id(self). So even though the values were equal, the hash is unequal because each instance has different ids. The test was probably just a sanity check to make sure they were different objects.

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

No branches or pull requests

2 participants