基于注释语法的clos风格通用函数
PyCLOS的Python项目详细描述
pyclos为python 3实现clos风格的通用函数。当前 实现是纯python,可选地依赖于c 实现了lru dict,用于在 价值专业化。
示例用法:
from py_clos import generic @generic def display(what, where): return "{} on {}".format(what, where) @generic.around def display(what, where: Webpage, next_method): return "<html>{}</html>".format(next_method(what, where)) @generic def display(what: User, where): return "user"