On 27Apr2020 2237, t...@tomforb.es wrote:
2. Special casing "lru_cache" to account for zero arity methods isn't trivial and we 
shouldn't endorse lru_cache as a way of achieving "call_once" semantics

Why not? It's a decorator, isn't it? Just make it check for number of arguments at decoration time and return a different object.

That way, people can decorate their functions now and get correct behaviour (I assume?) on 3.8 and earlier, and also a performance improvement on 3.9, without having to do any version checking.

This part could even be written in Python.

3. Implementing a thread-safe (or even non-thread safe) "call_once" method is 
non-trivial

Agree that this is certainly true. But presumably we should be making lru_cache thread safe if it isn't.

4. It complements the lru_cache and cached_property methods currently present 
in functools.

It's unfortunate that cached_property doesn't work at module level (as was pointed out on the other threads - thanks for linking those, BTW).

Cheers,
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/JNIOOBGOMTNGQTSRCBDBS7WAT4H65A4P/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to