[issue35040] [functools] provide an async-compatible version of functools.lru_cache
Liran Nuna
report at bugs.python.org
Tue May 28 16:44:49 EDT 2019
Liran Nuna <liranuna at gmail.com> added the comment:
> A coroutine detection is a relatively slow check.
> I don't think we need to do it in `functools.lru_cache`.
Wouldn't a coroutine check only happen during decoration time? To successfully solve this easily and efficiently, we only really need to wrap the coroutine with `asyncio.ensure_future` if the decorated function is a coroutine, and it will only happen when a result comes back from the decorated function which would have minimal impact.
Of course, I don't know much about the internals of `lru_cache` so my assumptions could be wrong. I should familiar myself with the implementation and figure out how doable it would be.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35040>
_______________________________________
More information about the Python-bugs-list
mailing list