perf: faster element deletion during matching (#4882)

* perf: faster deletion

* fix: leave the tuple init
This commit is contained in:
Roelof van Dijk 2024-06-08 15:16:35 +02:00 committed by GitHub
parent 0eebb8e998
commit 794fecf8e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -269,8 +269,10 @@ class UOpGraph:
changed += recurse_cnt
# NOTE: this changes UOp, so we have to delete caches
up.vin = tuple(rewrite(x) for x in up.vin)
if hasattr(up, "parents"): del up.parents
if hasattr(up, "cmp_tuple"): del up.cmp_tuple
try: del up.parents
except AttributeError: pass
try: del up.cmp_tuple
except AttributeError: pass
# replace with cached nodes
if found:=self.nodes.get(key:=up.tuple()): return found
self.nodes[key] = up