MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / dispatch

Function dispatch

tools/python-3.11.9-amd64/Lib/functools.py:818–839  ·  view source on GitHub ↗

generic_func.dispatch(cls) -> Runs the dispatch algorithm to return the best available implementation for the given *cls* registered on *generic_func*.

(cls)

Source from the content-addressed store, hash-verified

816 cache_token = None
817
818 def dispatch(cls):
819 """generic_func.dispatch(cls) -> <function implementation>
820
821 Runs the dispatch algorithm to return the best available implementation
822 for the given *cls* registered on *generic_func*.
823
824 """
825 nonlocal cache_token
826 if cache_token is not None:
827 current_token = get_cache_token()
828 if cache_token != current_token:
829 dispatch_cache.clear()
830 cache_token = current_token
831 try:
832 impl = dispatch_cache[cls]
833 except KeyError:
834 try:
835 impl = registry[cls]
836 except KeyError:
837 impl = _find_impl(cls, registry)
838 dispatch_cache[cls] = impl
839 return impl
840
841 def _is_union_type(cls):
842 from typing import get_origin, Union

Callers 1

wrapperFunction · 0.70

Calls 3

get_cache_tokenFunction · 0.90
_find_implFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected