Message263754
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. |
|
Date |
User |
Action |
Args |
2016-04-19 17:24:44 | josh.r | set | recipients:
+ josh.r, vstinner, martin.panter, serhiy.storchaka, yselivanov, llllllllll |
2016-04-19 17:24:44 | josh.r | set | messageid: <1461086684.64.0.417911088134.issue26802@psf.upfronthosting.co.za> |
2016-04-19 17:24:44 | josh.r | link | issue26802 messages |
2016-04-19 17:24:44 | josh.r | create | |
|