We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 609858f commit 3c2eefeCopy full SHA for 3c2eefe
Lib/functools.py
@@ -902,9 +902,13 @@ def dispatch(cls_obj):
902
if cache_token != current_token:
903
dispatch_cache.clear()
904
cache_token = current_token
905
- try:
906
- impl = dispatch_cache[cls]
907
- except KeyError:
+
+ # if PEP-585 types are not registered for the given *cls*,
908
+ # then we can use the cache. Otherwise, the cache cannot be used
909
+ # because we need to confirm every item matches first
910
+ from typing import get_origin
911
+ if not any(i for i in registry.keys() if get_origin(i) == cls):
912
try:
913
impl = registry[cls]
914
except KeyError:
0 commit comments