Skip to content

Commit 0861bb6

Browse files
authored
Reduce max protocol stack size to 20 (#22053)
With all the recent optimizations, largest protocol stack size used in `mypy_primer` is now 10, so I think it is safe to reduce the maximum size to 20. This should improve performance in extreme cases (with true divergent protocols).
1 parent ae5ca6f commit 0861bb6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎mypy/types.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,9 @@ class SentinelValue(NamedTuple):
224224

225225
# Maximum protocol subtyping assumptions depth. We need this to avoid infinite
226226
# recursion for protocols that are genuinely undecidable, see testDivergingProtocol.
227-
# Note we set very large cut-off for now, since some numerical libraries currently
228-
# use ~25 assumptions, and we want to avoid false negatives with them. We may be able
229-
# to reduce this in the future if we will optimize our callable unification logic.
230-
MAX_PROTOCOL_DEPTH: Final = 40
227+
# We set a conservative cut-off, since some numerical libraries currently
228+
# use ~10 assumptions, and we want to avoid false negatives with them.
229+
MAX_PROTOCOL_DEPTH: Final = 20
231230

232231

233232
class TypeOfAny:

0 commit comments

Comments
 (0)