python-attrs / python-attrs/attrs
Allow to pass a callable for field-level hash
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 480
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 2
Description
Apparently, being able to customize the hashing of individual fields is something interesting for NumPy users: https://stackoverflow.com/q/74975393/476759
I guess the idea would be to create a __hash__ that looks like this:
def __hash__(self):
return hash((self.a, custom_hash_for_b(self.b)))
while injecting custom_hash_for_b into eval's globals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by investigating the generated hash implementation and how eval globals are assembled; the issue does not name specific files or tests. Define how a callable for an individual field would be supplied and verify that generated hashes use it while preserving the other fields' hashing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100