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 asvetlov, rhettinger, serhiy.storchaka, uranusjr, yselivanov
Date 2022-02-23.16:55:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645635307.48.0.136453653253.issue46622@roundup.psfhosted.org>
In-reply-to
Content
async_lru_cache() and async_cached_property() can be written using that decorator. The implementation of async_lru_cache() is complicated because the interface of lru_cache() is complicated. But it is simpler than using _lru_cache_wrapper().

def async_lru_cache(maxsize=128, typed=False):
    if callable(maxsize) and isinstance(typed, bool):
        user_function, maxsize = maxsize, 128
        return lru_cache(maxsize, typed)(reawaitable(user_function))

    def decorating_function(user_function):
        return lru_cache(maxsize, typed)(reawaitable(user_function))

    return decorating_function

def async_cached_property(user_function):
    return cached_property(reawaitable(user_function))
History
Date User Action Args
2022-02-23 16:55:07serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, asvetlov, yselivanov, uranusjr
2022-02-23 16:55:07serhiy.storchakasetmessageid: <1645635307.48.0.136453653253.issue46622@roundup.psfhosted.org>
2022-02-23 16:55:07serhiy.storchakalinkissue46622 messages
2022-02-23 16:55:07serhiy.storchakacreate