Python 3.8 支持只接受位置参数了
2021 4 17 06:09 PM 0 条评论 406 次查看
functools.cache
的源码时发现参数列表有个诡异的 /
:def cache(user_function, /):
'Simple lightweight unbounded cache. Sometimes called "memoize".'
return lru_cache(maxsize=None)(user_function)
翻了下文档才发现这个叫 Positional-Only Parameters。