[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-24 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Andrew Svetlov] > A third-party library should either copy all these > implementation details or import a private function from stdlib OrderedDict provides just about everything needed to roll lru cache variants. It simply isn't true this can only be

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-24 Thread Joongi Kim
Change by Joongi Kim : -- nosy: +achimnol ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: 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

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think that it would be simpler to add a decorator which wraps the result of an asynchronous function into an object which can be awaited more than once: def reawaitable(func): @wraps(func) def wrapper(*args, **kwargs): return

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-23 Thread Tzu-ping Chung
Tzu-ping Chung added the comment: Another thing to point out is that existing third-party solutions (both alru_cache and cached_property) only work for asyncio, and the stdlib version (as implemented now) will be an improvement. And if the position is that the improvements should only be

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-23 Thread Andrew Svetlov
Andrew Svetlov added the comment: Thanks, Raymond. I agree that caching of iterators and generators is out of the issue scope. Also, I agree that a separate async cache decorator should be added. I prefer the `async_lru_cache` (and maybe `async_cache` for the API symmetry). We have

[issue46622] Add an async variant of lru_cache for coroutines.

2022-02-22 Thread Raymond Hettinger
Change by Raymond Hettinger : -- title: Add a async variant of lru_cache for coroutines. -> Add an async variant of lru_cache for coroutines. ___ Python tracker ___

[issue46622] Add a async variant of lru_cache for coroutines.

2022-02-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: 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