fluentpython / example-code

Example code for the book Fluent Python, 1st Edition (O'Reilly, 2015)
http://bit.ly/fluentpy
MIT License
5.56k stars 2.18k forks source link

modified Vector v4 equality check #35

Open adnanmuttaleb opened 4 years ago

adnanmuttaleb commented 4 years ago

According to my understanding of hashing and equality, I tried to enhance the performance of equality checking by ensuring that __eq__ does not perform component based comparison only if vectors has the same hash values (if two hashes is different then the two vectors are definitely unequal). because if two vectors has same hash value then: