
On Tue, 12 Jan 2021 at 17:16, Christopher Barker <pythonchb@gmail.com> wrote:
Is the implementation of lru_cache too opaque to poke into it without an existing method? Or write a quick monkey-patch?
Sorry for not checking myself, but the ability to do that kind of thing is one of the great things about a dynamic open source language.
I've only looked at the Python implementation, but the cache is a local variable in the wrapper, unavailable from outside. The cache information function is a closure that references that local variable, assigned as an attribute of the wrapped function. It's about as private as it's possible to get in Python (not particularly because it's *intended* to hide anything, as far as I can tell, more likely for performance or some other implementation reason). Paul