On Tue, Apr 28, 2020 at 11:45:49AM -0700, Raymond Hettinger wrote: > It seems like you would get just about everything you want with one line: > > once = lru_cache(maxsize=None)
But is it thread-safe? If you have a "once"ed expensive function with side-effects, and a second thread calls it before the first thread's initial call has completed, won't you end up executing the function twice? The documentation doesn't mention anything about thread-safety: https://docs.python.org/3/library/functools.html#functools.lru_cache -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/PR6CS6BMJV4YGXG7MER6OU2KWR6OCOVB/ Code of Conduct: http://python.org/psf/codeofconduct/