MCPcopy
hub / github.com/dask/dask / dispatch

Method dispatch

dask/utils.py:744–775  ·  view source on GitHub ↗

Return the function implementation for the given ``cls``

(self, cls)

Source from the content-addressed store, hash-verified

742 return wrapper(func) if func is not None else wrapper
743
744 def dispatch(self, cls):
745 """Return the function implementation for the given ``cls``"""
746 lk = self._lookup
747 if cls in lk:
748 return lk[cls]
749 for cls2 in cls.__mro__:
750 # Is a lazy registration function present?
751 try:
752 toplevel, _, _ = cls2.__module__.partition(".")
753 except Exception:
754 continue
755 try:
756 register = self._lazy[toplevel]
757 except KeyError:
758 pass
759 else:
760 register()
761 self._lazy.pop(toplevel, None)
762 meth = self.dispatch(cls) # recurse
763 lk[cls] = meth
764 lk[cls2] = meth
765 return meth
766 try:
767 impl = lk[cls2]
768 except KeyError:
769 pass
770 else:
771 if cls is not cls2:
772 # Cache lookup
773 lk[cls] = impl
774 return impl
775 raise TypeError(f"No dispatch for {cls}")
776
777 def __call__(self, arg, *args, **kwargs):
778 """

Callers 15

__call__Method · 0.95
__doc__Method · 0.95
test_dispatchFunction · 0.95
test_dispatch_lazyFunction · 0.95
concatFunction · 0.45
is_categorical_dtypeFunction · 0.45
categorical_dtypeFunction · 0.45
tolistFunction · 0.45
make_metaFunction · 0.45
union_categoricalsFunction · 0.45

Calls 1

popMethod · 0.80

Tested by 3

test_dispatchFunction · 0.76
test_dispatch_lazyFunction · 0.76