MCPcopy Create free account
hub / github.com/dask/dask / dispatch

Method dispatch

dask/utils.py:743–774  ·  view source on GitHub ↗

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

(self, cls)

Source from the content-addressed store, hash-verified

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

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