2 ms·
Having mylist stick around is actually useful for making stateful functions. For example, I've often used def foo(..., cache={}): ... to implement cach
by klyrs 5y ago
Having mylist stick around is actually useful for making stateful functions. For example, I've often used
def foo(..., cache={}):
...
to implement cached functions, or functions which need an internal cache for whatever reason. Later versions of Python provide an lru cache decorator, but that doesn't help with the internal cache and can be inefficient when you don't want your cache to forget any results.