Add __hash__ method for permissions.OperandHolder class#9417
Add __hash__ method for permissions.OperandHolder class#9417auvipy merged 1 commit intoencode:masterfrom
__hash__ method for permissions.OperandHolder class#9417Conversation
`OperandHolder` is not hashable, so need to add `__hash__` method
peterthomassen
left a comment
There was a problem hiding this comment.
lgtm, sorry being slow.
|
thanks anyway. merged as it was small, after cross checking |
|
We should really have tests for this. @vanya909 can you make a follow-up PR with a test that hashes an instance? |
|
Can you explain why using |
It's useful in cases when we want to filter out unique permissions in order to avoid calculating of some complex permissions two or more times Of course it can be done by just iterating over permissions list and appending in a result list those permissions which haven't been added yet, but using In case when we want to keep original order of permissions |
|
Also, this fixes the regression introduced by #8710, so don't think it requires justification beyond that |
OperandHolderis not hashable, so need to add__hash__methodDescription
OperandHolderis not hashable after #8710, need to add__hash__method to it to provide convenient syntax to filter unique permissions usingsetordict.fromkeysWays to represent
Fixes
__eq__method fromOperandHolderor
__hash__method toOperandHolderSecond way is provided in this PR