question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implementing `__hash__` and `__eq__` for `BatchedSend`

See original GitHub issue

In Scheduler.report we collect a set of comms for the Clients. Looking more closely at the contents of self.client_comms, it appears to just contain BatchedSend objects. Putting these objects in a set will wind up using __eq__ and __hash__. Neither of these appear to be defined by BatchedSend. As a result a good chunk of time is spent hashing these objects by some fallback mechanism before adding them to the set in Scheduler.report. Would be good to have implementations of __eq__ and __hash__ for BatchedSend to avoid this issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jakirkhamcommented, Nov 24, 2020

Found a good way to do this with a dict ( https://github.com/dask/distributed/pull/4275 ), which should get us past this issue. It may be possible to simplify this further to a list, but that might not matter much.

0reactions
mrocklincommented, Nov 24, 2020

We can also ask @jrbourbeau to do this if y’all are less familiar here. James is fairly adept at these sorts of changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Recommended way to implement __eq__ and __hash
Answering my own question. It seems one way of performing this is to define an auxillary __members function and to use that in...
Read more >
Hashing and Equality in Python - Lyft Engineering
Let's first dive into how objects work if we don't implement __hash__ and __eq__ . By default, equality and hashes are based on...
Read more >
Python Hashes and Equality - Hynek Schlawack
To make a class hashable, it has to implement both the __hash__(self) method and the aforementioned __eq__(self, other) method.
Read more >
Understanding Hashing and Equality in Python with __hash ...
The __eq__ operator in Python is a method for overloading the default == operator, i.e. to define if two objects are equal. It...
Read more >
Hash in std::hash - Rust
A hashable type. Types implementing Hash are able to be hash ed with an instance of Hasher . Implementing Hash. You can derive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found