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

refactor __eq__ and __hash__ methods #136

Closed
CunliangGeng opened this issue Apr 5, 2023 · 0 comments
Closed

refactor __eq__ and __hash__ methods #136

CunliangGeng opened this issue Apr 5, 2023 · 0 comments
Assignees
Labels
scoring issues related to scoring part

Comments

@CunliangGeng
Copy link
Member

CunliangGeng commented Apr 5, 2023

Follow the guide to refactor __hash__ and __eq__ methods in all relevant classes.

https://docs.python.org/3.10/glossary.html

hashable:
An object is hashable

  • if it has a hash value which never changes during its lifetime (it needs a hash() method),
  • and can be compared to other objects (it needs an eq() method).
    Hashable objects which compare equal must have the same hash value.

Hashability makes an object usable as a dictionary key and a set member, because these data structures use the hash value internally.

Most of Python’s immutable built-in objects are hashable; mutable containers (such as lists or dictionaries) are not; immutable containers (such as tuples and frozensets) are only hashable if their elements are hashable. Objects which are instances of user-defined classes are hashable by default. They all compare unequal (except with themselves), and their hash value is derived from their id().

@CunliangGeng CunliangGeng added this to the refactor codebase milestone Apr 5, 2023
@CunliangGeng CunliangGeng self-assigned this Apr 5, 2023
@CunliangGeng CunliangGeng added the scoring issues related to scoring part label Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scoring issues related to scoring part
Projects
Status: Done
Development

No branches or pull requests

1 participant