perf: faster lazyop eq (#1693)

Co-authored-by: Roelof van Dijk <roelof.van.dijk@vitestro.com>
This commit is contained in:
Roelof van Dijk 2023-08-27 17:17:02 +02:00 committed by GitHub
parent 6ca509a485
commit 2730ed657f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 4 deletions

View File

@ -32,10 +32,7 @@ class LazyOp:
except AttributeError: self.buffers = ()
def __repr__(self): return f"LazyOp(op={self.op}, src={self.src}, arg={self.arg})"
def __eq__(self, __value: object) -> bool:
if __value.__class__ is not LazyOp: return False
__value = cast(LazyOp, __value)
return self.op == __value.op and self.src == __value.src and self.arg == __value.arg
def __eq__(self, __value: object) -> bool: return isinstance(__value, LazyOp) and self.op is __value.op and self.src == __value.src and self.arg == __value.arg
def __hash__(self) -> int: return hash((self.op, self.src, self.arg))
@property
def key(self): return (self.op, tuple(map(lambda x: getattr(x, "key", x), self.src)), getattr(self.arg, "key", self.arg))