[Python-ideas] Possibility to decorate single code line or code block?

2020-12-18 Thread Stephen J. Turnbull
Marco Sulla writes: > Maybe it's a crazy idea, but what if we could decorate a single line > of code? > For example: > > @Timer > a = time_consuming_function() As syntax, I don't see the advantage over with ContextManagingTimer(): a = time_consuming_function() I don't underst

[Python-ideas] Possibility to decorate single code line or code block?

2020-12-18 Thread Marco Sulla
Maybe it's a crazy idea, but what if we could decorate a single line of code? For example: @Timer a = time_consuming_function() This will be equivalent to using Steven's context manager, but the decorator is more simple to comment and uncomment. Maybe it could be possible to comment also code bl