Closed vanya909 closed 3 weeks ago
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 set(...)
on these classes is useful?
@tomchristie
Can you explain why using set(...) on these classes is useful?
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 set()
is more simple
In case when we want to keep original order of permissions dict.fromkeys()
can be used, I would say dict.fromkeys()
is preferable, but it also requires all permissions to be hashable
Also, this fixes the regression introduced by #8710, so don't think it requires justification beyond that
OperandHolder
is not hashable, so need to add__hash__
methodDescription
OperandHolder
is not hashable after #8710, need to add__hash__
method to it to provide convenient syntax to filter unique permissions usingset
ordict.fromkeys
Ways to represent
Fixes
__eq__
method fromOperandHolder
or__hash__
method toOperandHolder
Second way is provided in this PR