Author josh.r
Recipients josh.r, llllllllll, martin.panter, serhiy.storchaka, vstinner, yselivanov
Date 2016-04-19.17:24:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461086684.64.0.417911088134.issue26802@psf.upfronthosting.co.za>
In-reply-to
Content
BTW, for a realistic use case that would be sped up by this patch (possibly a lot), consider a recursive function that is continually doing a "virtual" pop of the first argument, and receiving the rest as varargs, which are then unpacked for the recursive call, e.g., a function to make a multidimensional list populated with zeroes:

    def nestedzeroes(firstdim, *dims):
        '''Make multidimensional list populated with 0s'''
        if not dims:
            return [0] * firstdim
        return [nestedzeroes(*dims) for _ in range(firstdim)]

It's somewhat less artificial in that it multiplies the effect of the optimization in a way that would actually exercise a microbenchmark-like scenario, where the amount of work involved in the star-args-only function calls is an appreciable percentage of the work. Running nestedzeroes(5, 5, 5) to create a 5x5x5 structure would involve 30 recursive calls; for nestedzeroes(10, 10, 10), 110 recursive calls.

I've actually used code like this (admittedly rarely) to avoid the hassle of inlining a many times nested set of list comprehensions to initialize a multidimensional list.
History
Date User Action Args
2016-04-19 17:24:44josh.rsetrecipients: + josh.r, vstinner, martin.panter, serhiy.storchaka, yselivanov, llllllllll
2016-04-19 17:24:44josh.rsetmessageid: <1461086684.64.0.417911088134.issue26802@psf.upfronthosting.co.za>
2016-04-19 17:24:44josh.rlinkissue26802 messages
2016-04-19 17:24:44josh.rcreate