Message327261
I made this simple time decorator, it's not perfect but it does make python more pythonic :) :
it can be used as a decorator:
```
@timef
def fun_to_time(a, b):
...
```
or as a function call
`timef(print)("Hello world!")`
just a simple decorator no need for
`timeit.timeit("fun_to_time(a, b)", setup="from __main__ import a, b", number=1)`
it's also customizable as you can control number of repetitions, garbage collection, unit ...
and it produces a formatted output such as:
`fun_to_time: 24.1056 ms`.
It is somewhat badly written so waiting for your word people of wisdom :).
I think python needs this in the standard library as the current way is (sometimes) tedious. |
|
Date |
User |
Action |
Args |
2018-10-06 23:46:31 | amjad ben hedhili | set | recipients:
+ amjad ben hedhili |
2018-10-06 23:46:30 | amjad ben hedhili | set | messageid: <1538869590.35.0.545547206417.issue34917@psf.upfronthosting.co.za> |
2018-10-06 23:46:30 | amjad ben hedhili | link | issue34917 messages |
2018-10-06 23:46:30 | amjad ben hedhili | create | |
|