Message265418
On Thu, May 12, 2016 at 04:49:59AM +0000, Nick Coghlan wrote:
> The embedded side-effects were my main concern with Scott's original
> patch, so Steven's callback-based approach strikes me as a definite
> improvement. However, the awkwardness of the revised calling code in
> main does make me wonder whether or not this might be better
> implemented as a generator rather than as a function accepting a
> callback:
I thought about a generator too, but then I thought about the *non*
verbose case, where you don't care about the intermediate results, only
the final (number, time_taken) pair.
# function with callback:
number, time_taken = t.autorange()
# generator
number, time_taken = list(t.autorange())[-1]
Which hints that your code snippet is buggy, or at least incomplete:
> try:
> results = list(t.autorange())
> except:
> t.print_exc()
> return 1
> if verbose:
> for number, time_taken in results:
> msg = "{} loops -> {:.{}g} secs"
> print(msg.format(number, time_taken, precision))
If verbose is False, you never set number and time_taken. So you need an
else clause:
else:
number, time_taken = results[-1] |
|
Date |
User |
Action |
Args |
2016-05-12 16:49:28 | steven.daprano | set | recipients:
+ steven.daprano, rhettinger, scott_daniels, amaury.forgeotdarc, ncoghlan, pitrou, vstinner, rbcollins, eric.araujo, asvetlov, tshepang |
2016-05-12 16:49:28 | steven.daprano | link | issue6422 messages |
2016-05-12 16:49:28 | steven.daprano | create | |
|