This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: add time decorator to timeit.py
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: amjad ben hedhili, ezio.melotti
Priority: normal Keywords:

Created on 2018-10-06 23:46 by amjad ben hedhili, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
timeit.py amjad ben hedhili, 2018-10-06 23:46 lib/timeit.py (line 240)
Messages (2)
msg327261 - (view) Author: AmjadHD (amjad ben hedhili) Date: 2018-10-06 23:46
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.
msg327262 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2018-10-07 01:09
Thanks for the decorator, however this should probably be discussed on python-ideas first to decide if a decorator should be added in the first place.  If the idea is accepted, the exact implementation should be discussed and defined, and finally a pull request should be submitted.
The decorator you submitted can't be accepted as it is, so for the time being, I'm going to reject it and close the issue.
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 79098
2018-10-07 01:09:28ezio.melottisetstatus: open -> closed

versions: + Python 3.8, - Python 3.7
nosy: + ezio.melotti

messages: + msg327262
resolution: rejected
stage: resolved
2018-10-06 23:46:30amjad ben hedhilicreate