From a3dac67560c0db98829f78f89853d78d41cfccd7 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Sat, 12 Jul 2025 12:32:36 +0100 Subject: [PATCH] Micro-optimization: Avoid temporary set creation is_proper_subtype This is a part of a set of micro-optimizations that improve self check performance by ~5.5%. --- mypy/subtypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypy/subtypes.py b/mypy/subtypes.py index 428e6dec6749..c6162257050d 100644 --- a/mypy/subtypes.py +++ b/mypy/subtypes.py @@ -213,8 +213,8 @@ def is_proper_subtype( keep_erased_types=keep_erased_types, ) else: - assert not any( - {ignore_promotions, erase_instances, keep_erased_types} + assert ( + not ignore_promotions and not erase_instances and not keep_erased_types ), "Don't pass both context and individual flags" if type_state.is_assumed_proper_subtype(left, right): return True