Message265360
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:
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))
(Originally I had the "if verbose: print" embedded in a direct loop over t.autorange(), but writing it that way made it immediately clear that the scope of the exception handler was too broad, so I changed it to extract all the results and only then print them) |
|
Date |
User |
Action |
Args |
2016-05-12 04:49:58 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger, scott_daniels, amaury.forgeotdarc, pitrou, vstinner, rbcollins, eric.araujo, steven.daprano, asvetlov, tshepang |
2016-05-12 04:49:58 | ncoghlan | set | messageid: <1463028598.38.0.991195359239.issue6422@psf.upfronthosting.co.za> |
2016-05-12 04:49:58 | ncoghlan | link | issue6422 messages |
2016-05-12 04:49:58 | ncoghlan | create | |
|