[Python-ideas] functools.lru_cache manual cache modification

Constantin Berhard constantin at exxxtremesys.lu
Wed Dec 3 23:24:57 CET 2014

On 03.12.2014 22:22, Andrew Barnert wrote:
> Maybe just providing the original version as a recipe in functools, as an "equivalent to..." block to show people how to roll their own, would solve the problem well enough for this thread?
Actually no, this doesn't solve my problem at all. Independent of the
inner implementation of lru_cache I need to be able to manually add and
lookup key-value pairs from the outside.

I need this to make my decorator compatible with lru_cache.
It's only 27 lines of code, you may read it if you want to understand my
problem. (additionally 62 lines of example code)

The problem is that the exception carrying the arguments->return_data
information is thrown past the lru_cache decorator because it can't
catch it.

Best Regards,

More information about the Python-ideas mailing list