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

Re: on implementing a toy oop-system

2022-09-28 Thread Meredith Montgomery
Meredith Montgomery writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> Meredith Montgomery writes: >>>Is that at all possible somehow? Alternatively, how would you do your >>>toy oop-system? >> >> Maybe something along those lines: >> >> from functools import partial >> >> def counte