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 Itayazolay
Recipients Itayazolay
Date 2020-07-06.16:51:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1594054270.54.0.203199023298.issue41220@roundup.psfhosted.org>
In-reply-to
Content
I'd like to add optional argument to lru_cache.
This argument is a user given function that will replace the default behaviour of creating a key from the args/kwds of the function.

for example:

def my_make_key(my_list):
  return my_list[0]

@lru_cache(128, make_key=my_make_key)
def cached_func(my_list):
  return sum(my_list)

This will creating a cached function that accepts immutable.
Also, It will allow user to add custom functions from knowledge about the expected function input, without the need to create custom classes and/or overriding __hash__
History
Date User Action Args
2020-07-06 16:51:10Itayazolaysetrecipients: + Itayazolay
2020-07-06 16:51:10Itayazolaysetmessageid: <1594054270.54.0.203199023298.issue41220@roundup.psfhosted.org>
2020-07-06 16:51:10Itayazolaylinkissue41220 messages
2020-07-06 16:51:10Itayazolaycreate