本文整理匯總了Python中functools._find_impl方法的典型用法代碼示例。如果您正苦於以下問題:Python functools._find_impl方法的具體用法?Python functools._find_impl怎麽用?Python functools._find_impl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類functools
的用法示例。
在下文中一共展示了functools._find_impl方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: applicationpolicy2
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import _find_impl [as 別名]
def applicationpolicy2(arg: Callable) -> Callable:
"""
This one doesn't use weakrefs.
"""
handlers = {}
cache = {}
def _mutator(func):
def dispatch(event_type):
try:
return cache[event_type]
except KeyError:
handler = _find_impl(event_type, handlers) or func
cache[event_type] = handler
return handler
@wraps(func)
def policy_function_wrapper(*args, **kwargs):
event = kwargs.get("event") or args[-1]
return dispatch(type(event))(*args, **kwargs)
def register(event_type):
def registered_function_decorator(func):
handlers[event_type] = func
return func
return registered_function_decorator
policy_function_wrapper.register = register
return policy_function_wrapper
return _mutator(arg)
示例2: _write_method
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import _find_impl [as 別名]
def _write_method(cls: Type[T]) -> Callable[[H5Group, str, T], None]:
return _find_impl(cls, H5AD_WRITE_REGISTRY)
示例3: _write_method
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import _find_impl [as 別名]
def _write_method(cls: Type[T]) -> Callable[[zarr.Group, str, T], None]:
return _find_impl(cls, ZARR_WRITE_REGISTRY)