Author ncoghlan
Recipients amaury.forgeotdarc, asvetlov, haypo, merwok, ncoghlan, pitrou, rbcollins, rhettinger, scott_daniels, steven.daprano, tshepang
Date 2016-05-12.04:49:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463028598.38.0.991195359239.issue6422@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2016-05-12 04:49:58ncoghlansetrecipients: + ncoghlan, rhettinger, scott_daniels, amaury.forgeotdarc, pitrou, haypo, rbcollins, merwok, steven.daprano, asvetlov, tshepang
2016-05-12 04:49:58ncoghlansetmessageid: <1463028598.38.0.991195359239.issue6422@psf.upfronthosting.co.za>
2016-05-12 04:49:58ncoghlanlinkissue6422 messages
2016-05-12 04:49:58ncoghlancreate