Skip to content

Conversation

@m-burst
Copy link
Contributor

@m-burst m-burst commented Nov 8, 2018

The added implementation XORs the tuple.__hash__ of the data object with the hash of the class. This should help to avoid collisions between instances of different data types with identical members.

Also added a test which ensures that:

  • hash of a data type instance can be computed;
  • hashes of instances of different data types with same data differ;
  • hash of a data type instance differs from hash of a plain tuple.

Fixes #446.

@evhub
Copy link
Owner

evhub commented Nov 9, 2018

@m-burst This looks great; thanks a lot! Can you also add a test to make sure that the hash is in fact the same for identical data types? It's just nice to have a test both for the positive case and for the negative case.

@evhub evhub added this to the v1.4.1 milestone Nov 9, 2018
The added implementation XORs the `tuple.__hash__` of the data object
with the hash of the class.  This should help to avoid collisions
between instances of different data types with identical members.

Also added a test which ensures that:
* hash of a data type instance can be computed;
* hashes of instances of different data types with same data differ;
* hash of a data type instance differs from hash of a plain tuple.

Fixes #446.
@m-burst
Copy link
Contributor Author

m-burst commented Nov 9, 2018

@evhub Added a simple positive test case.

@evhub evhub added the resolved label Nov 9, 2018
@evhub evhub closed this Nov 9, 2018
@evhub evhub reopened this Nov 9, 2018
@evhub evhub merged commit c607dad into evhub:develop Nov 9, 2018
@m-burst m-burst deleted the data-hash branch November 9, 2018 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants