[issue44003] functools.lru_cache omits __defaults__ attribute from wrapped function
Raymond Hettinger
report at bugs.python.org
Sat May 1 20:17:47 EDT 2021
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
I don't think this should be done. We want the lru_cache to be a pass-through. Applying defaults or keyword-only/positional-only restrictions is the responsibility of the inner function.
FWIW, here are the fields that Nick selected to be included in update_wrapper(): ('__module__', '__name__', '__qualname__', '__doc__', '__annotations__').
Those are sufficient to get help() to work which is all we were aiming for:
>>> from functools import *
>>> @lru_cache
def cached_func(b=5):
pass
>>> help(cached_func)
Help on _lru_cache_wrapper in module __main__:
cached_func(b=5)
----------
nosy: +rhettinger
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44003>
_______________________________________
More information about the Python-bugs-list
mailing list