Skip to content

Commit c53367f

Browse files
authored
Use cache for OpExpr (#19523)
Fixes #14978 This is irrelevant for self-check (and for most code likely), but it is important for numerical code, where it avoids exponential slowdown in formulas involving arrays etc (see e.g. the original issue). Unless there will be fallout in `mypy_primer` and/or there are objections, I am going to go ahead and merge it.
1 parent 703bee9 commit c53367f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mypy/checkexpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6043,7 +6043,7 @@ def accept(
60436043
# We cannot use cache inside lambdas, because they skip immediate type
60446044
# context, and use enclosing one, see infer_lambda_type_using_context().
60456045
# TODO: consider using cache for more expression kinds.
6046-
elif isinstance(node, (CallExpr, ListExpr, TupleExpr)) and not (
6046+
elif isinstance(node, (CallExpr, ListExpr, TupleExpr, OpExpr)) and not (
60476047
self.in_lambda_expr or self.chk.current_node_deferred
60486048
):
60496049
if (node, type_context) in self.expr_cache:

0 commit comments

Comments
 (0)