Skip to content

Commit 19bede2

Browse files
committed
cache simplified
1 parent cae4df1 commit 19bede2

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.fully_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.fully_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,8 @@ def simplify_once(self, dependents: defaultdict):
338342
expr = type(expr)(*new_operands)
339343

340344
break
341-
345+
if expr is self:
346+
expr.fully_simplified = True
342347
return expr
343348

344349
def simplify(self) -> Expr:

0 commit comments

Comments
 (0)