Skip to content

Commit 9645a65

Browse files
committed
cache simplified
1 parent cae4df1 commit 9645a65

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: dask_expr/_core.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __new__(cls, *args, **kwargs):
4848
return Expr._instances[_name]
4949

5050
Expr._instances[_name] = inst
51+
inst.simplified = False
5152
if inst._required_attribute:
5253
dep = next(iter(_dependencies))._meta
5354
if not hasattr(dep, inst._required_attribute):
@@ -299,9 +300,12 @@ def simplify_once(self, dependents: defaultdict):
299300
expr:
300301
output expression
301302
"""
303+
if self.simplified:
304+
return self
302305
expr = self
303-
306+
n = 0
304307
while True:
308+
n += 1
305309
out = expr._simplify_down()
306310
if out is None:
307311
out = expr
@@ -338,7 +342,7 @@ def simplify_once(self, dependents: defaultdict):
338342
expr = type(expr)(*new_operands)
339343

340344
break
341-
345+
expr.simplified = True
342346
return expr
343347

344348
def simplify(self) -> Expr:
@@ -349,6 +353,7 @@ def simplify(self) -> Expr:
349353
if new._name == expr._name:
350354
break
351355
expr = new
356+
# print(f"Cache has size {len(_seen)=}")
352357
return expr
353358

354359
def _simplify_down(self):

0 commit comments

Comments
 (0)