Re: [Python-ideas] add a time decorator to timeit.py

2018-10-09 Thread Anders Hovmöller
> On 7 Oct 2018, at 22:44, Guido van Rossum wrote: > > So someone ought to submit a PR that adds (brief) documentation for this, > with reference to this thread. I was trying to write this documentation when I noticed that the docs already mention this! "The stmt and setup parameters can als

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-08 Thread Amjad Ben Hedhili
python-ideas Objet : Re: [Python-ideas] add a time decorator to timeit.py Summary: Python's timeit.timeit() has an undocumented feature / implementation detail that gives much of what the original poster has asked for. Perhaps revising the docs will solve the problem. This thread has promp

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Guido van Rossum
So someone ought to submit a PR that adds (brief) documentation for this, with reference to this thread. On Sun, Oct 7, 2018 at 12:50 PM Jonathan Fine wrote: > On 7 Oct 2018 20:39, "Michael Selik" wrote: > > Isn't there some rule about noticing an undocumented feature, like, > whoever pours the

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Jonathan Fine
On 7 Oct 2018 20:39, "Michael Selik" wrote: Isn't there some rule about noticing an undocumented feature, like, whoever pours the last cup of coffee needs to brew a fresh pot? :-) Most of the credit belongs, I think, to the original poster. His statement, that Python wasn't very Pythonic here,

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Jonathan Fine
Summary: It's an undocumented feature, not an implementation detail. I wrote: > And if you're a software historian, now perhaps look at > https://github.com/python/cpython/commits/3.7/Lib/timeit.py Well, I've bitten my own bait, and have found it. See https://github.com/python/cpython/commi

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Jonathan Fine
Summary: Python's timeit.timeit() has an undocumented feature / implementation detail that gives much of what the original poster has asked for. Perhaps revising the docs will solve the problem. This thread has prompted me to look at timeit again. Usually, I look at the command line help first. >

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Amjad Ben Hedhili
Kotlin with the measureTimeMillis and measureNanoTime functions ...) and the implementation is open for change, it can be made better. De : Python-ideas de la part de Chris Angelico Envoyé : dimanche 7 octobre 2018 05:44 À : python-ideas Objet : Re: [Python

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Chris Angelico
On Sun, Oct 7, 2018 at 11:34 PM Steven D'Aprano wrote: > Unfortunately, not every good idea can or will make it into the std lib. > Even if the idea is good, we might decide that it belongs as a third- > party library, or that the benefit is not enough to make up for the cost > in effort or comple

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Steven D'Aprano
On Sun, Oct 07, 2018 at 11:43:40AM +, Amjad Ben Hedhili wrote: > this is my implementation: I didn't ask about the current implementation, as that might change. I asked about the interface: what it does, not how it does it. For the purposes of Python-Ideas, we want to discuss the feature, no

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Amjad Ben Hedhili
erfect but it works; you can control number of repetitions, garbage collection, unit ... and it produces a formatted output such as: `fun_to_time: 24.1056 ms`. De : Python-ideas de la part de Steven D'Aprano Envoyé : dimanche 7 octobre 2018 04:15 À : python-

Re: [Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Steven D'Aprano
On Sun, Oct 07, 2018 at 10:16:08AM +, Amjad Ben Hedhili wrote: > I think that a time decorator will be a useful addition to the sandard > library, as i find the current way of measuring execution time a bit > tedious: > > timeit.timeit("fun_to_time(a, b)", setup="from __main__ import a, b",

[Python-ideas] add a time decorator to timeit.py

2018-10-07 Thread Amjad Ben Hedhili
I think that a time decorator will be a useful addition to the sandard library, as i find the current way of measuring execution time a bit tedious: timeit.timeit("fun_to_time(a, b)", setup="from __main__ import a, b", number=1) compared to: @timef def fun_to_time(a, b): ... or timef(prin