Implementing `__hash__` and `__eq__` for `BatchedSend`
See original GitHub issueIn Scheduler.report
we collect a set
of comms
for the Client
s. 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:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 alist
, but that might not matter much.We can also ask @jrbourbeau to do this if y’all are less familiar here. James is fairly adept at these sorts of changes.