Hello, On Sat, 19 Dec 2020 21:24:40 +0300 Paul Sokolovsky <pmis...@gmail.com> wrote:
> Hello, > > On Sat, 19 Dec 2020 03:52:46 +0100 > Marco Sulla <marco.sulla.pyt...@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 class TimeIt: def __enter__(self): self.t = time.time() def __exit__(self, *args): delta = time.time() - self.t print("%ss" % delta) @TimeIt time.sleep(1) @TimeIt time.sleep(0.3); time.sleep(0.2) $ python3 -m imphook -i mod_stmt_deco -m example_stmt_deco 1.0011165142059326s 0.5011942386627197s -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ 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/4KVDGLMBIB3N3SD6FC6XX4PR4ALNTRBX/ Code of Conduct: http://python.org/psf/codeofconduct/