On Sat, 19 Dec 2020 21:24:40 +0300 Paul Sokolovsky email@example.com wrote:
On Sat, 19 Dec 2020 03:52:46 +0100 Marco Sulla Marco.Sulla.Python@gmail.com wrote:
Maybe it's a crazy idea, but what if we could decorate a single line of code?
Bottom line: this should be doable, and should be doable easily enough by any interested party.
Just wanted to let know that poorman's version already works:
$ cat example_stmt_deco.py import time
def __enter__(self): self.t = time.time()
def __exit__(self, *args): delta = time.time() - self.t print("%ss" % delta)
@TimeIt time.sleep(0.3); time.sleep(0.2)
$ python3 -m imphook -i mod_stmt_deco -m example_stmt_deco 1.0011165142059326s 0.5011942386627197s