本文整理汇总了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)