3 ms·
For trivial examples, sure. And there are a lot of those in practice, so it definitely applies sometimes. But decorators aren't really usable when you have an
by Groxx 6y ago
For trivial examples, sure. And there are a lot of those in practice, so it definitely applies sometimes. But decorators aren't really usable when you have any intermediate steps that need to be done, like
def do_thing():
with a_lock
check_f_cache_while_locked() # like this
with open('foo', 'r') as f
populate_cache(f)