Re: Implementation of an lru_cache() decorator that ignores the first argument

2022-09-30 Thread Heinrich Kruger
On Thursday, September 29th, 2022 at 07:18, Robert Latest via Python-list wrote: > Hi Chris and dh, > > thanks for your --as usually-- thoughtful and interesting answers. Indeed, > when > doing these web applications I find that there are several layers of useful, > maybe less useful, and unk

Re: Implementation of an lru_cache() decorator that ignores the first argument

2022-09-29 Thread Robert Latest via Python-list
Hi Chris and dh, thanks for your --as usually-- thoughtful and interesting answers. Indeed, when doing these web applications I find that there are several layers of useful, maybe less useful, and unknown caching. Many of my requests rely on a notoriously unreliable read-only database outside of m

Re: Implementation of an lru_cache() decorator that ignores the first argument

2022-09-28 Thread dn
On 29/09/2022 07.22, Robert Latest via Python-list wrote: ... > This is what I came up with. I'm quite happy with it so far. Question: Am I > being too clever? is it too complicated? Am I overlooking something that will > come back and bite me later? Thanks for any comments! Thank you for the ch

Re: Implementation of an lru_cache() decorator that ignores the first argument

2022-09-28 Thread Chris Angelico
On Thu, 29 Sept 2022 at 05:36, Robert Latest via Python-list wrote: > in a (Flask) web application I often find that many equal (SQLAlchemy) queries > are executed across subsequent requests. So I tried to cache the results of > those queries on the module level like this: > > @lru_cache() >

Implementation of an lru_cache() decorator that ignores the first argument

2022-09-28 Thread Robert Latest via Python-list
Hi all, in a (Flask) web application I often find that many equal (SQLAlchemy) queries are executed across subsequent requests. So I tried to cache the results of those queries on the module level like this: @lru_cache() def query_db(db, args): # do the "expensive" query r