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 rhettinger
Recipients asvetlov, rhettinger, serhiy.storchaka, uranusjr, yselivanov
Date 2022-02-23.02:43:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645584206.95.0.603702014713.issue46622@roundup.psfhosted.org>
In-reply-to
Content
If this goes forward, my strong preference is to have a separate async_lru() function  just like the referenced external project.

For non-async uses, overloading the current lru_cache makes it confusing to reason about. It becomes harder to describe clearly what the caches do or to show a pure python equivalent.  People are already challenged to digest the current capabilities and are already finding it difficult to reason about when references are held.  I don't want to add complexity, expand the docs to be more voluminous, cover the new corner cases, and add examples that don't make sense to non-async users (i.e. the vast majority of python users).  Nor do I want to update the recipes for lru_cache variants to all be async aware.  So, please keep this separate (it is okay to share some of the underlying implementation, but the APIs should be distinct).

Also as a matter of fair and equitable policy, I am concerned about taking the core of a popular external project and putting in the standard library.  That would tend to kill the external project, either stealing all its users or leaving it as something that only offers a few incremental features above those in the standard library.  That is profoundly unfair to the people who created, maintained, and promoted the project.

Various SC members periodically voice a desire to move functionality *out* of the standard library and into PyPI rather than the reverse.  If a popular external package is meeting needs, perhaps it should be left alone.

As noted by the other respondants, caching sync and async iterators/generators is venturing out on thin ice.  Even if it could be done reliably (which is dubious), it is likely to be bug bait for users.  Remember, we already get people who try to cache time(), random() or other impure functions.  They cache methods and cannot understand why references is held for the instance.  Assuredly, coroutines and futures will encounter even more misunderstandings. 

Also, automatic reiterability is can of worms and would likely require a PEP. Every time subject has come up before, we've decided not to go there.  Let's not make a tool that makes user's lives worse.  Not everything should be cached.  Even if we can, it doesn't mean we should.
History
Date User Action Args
2022-02-23 02:43:26rhettingersetrecipients: + rhettinger, asvetlov, serhiy.storchaka, yselivanov, uranusjr
2022-02-23 02:43:26rhettingersetmessageid: <1645584206.95.0.603702014713.issue46622@roundup.psfhosted.org>
2022-02-23 02:43:26rhettingerlinkissue46622 messages
2022-02-23 02:43:26rhettingercreate