This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Manjusaka, Scott Sanderson2, rhettinger, serhiy.storchaka
Date 2019-10-24.07:33:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571902407.8.0.871942398982.issue38565@roundup.psfhosted.org>
In-reply-to
Content
It is easy:

diff --git a/Lib/functools.py b/Lib/functools.py
index 3192bd02d9..52c07db749 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -499,7 +499,9 @@ def lru_cache(maxsize=128, typed=False):
         # The user_function was passed in directly via the maxsize argument
         user_function, maxsize = maxsize, 128
         wrapper = _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo)
-        return update_wrapper(wrapper, user_function)
+        func = update_wrapper(wrapper, user_function)
+        func.cache_parameters = lambda: {'maxsize': maxsize, 'typed': typed}
+        return func
     elif maxsize is not None:
         raise TypeError(
             'Expected first argument to be an integer, a callable, or None')

But there are many design questions. Why method instead of just attribute?

        func.cache_parameters = {'maxsize': maxsize, 'typed': typed}

Or maybe just add the "typed" attribute?

        func.typed = typed


Also I consider adding the more general "make_key" parameter to lru_cache(). The "typed" parameter would just specify the default value for "make_key".
History
Date User Action Args
2019-10-24 07:33:27serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, Scott Sanderson2, Manjusaka
2019-10-24 07:33:27serhiy.storchakasetmessageid: <1571902407.8.0.871942398982.issue38565@roundup.psfhosted.org>
2019-10-24 07:33:27serhiy.storchakalinkissue38565 messages
2019-10-24 07:33:27serhiy.storchakacreate