This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients brandtbucher, pablogsal, serhiy.storchaka
Date 2019-10-11.18:20:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570818035.53.0.99455845507.issue38436@roundup.psfhosted.org>
In-reply-to
Content
Thanks, Pablo, for providing that. So the changes look like mostly a wash on these benchmarks. 

Serhiy:

I do not see any significant change in + operator timing on my machine (again, just a rough test):

$ ./python.exe -m timeit -s z=0 z+0  # master
10000000 loops, best of 5: 21.3 nsec per loop

$ ./python.exe -m timeit -s z=0 z+0  # list-add
10000000 loops, best of 5: 21.2 nsec per loop

I'm aware that unpacking is "better". With that said, adding a list literal (or a slice of any list, or a list comprehension) to another list is a fairly common operation (I count several dozen examples in the stdlib). Even though these cases only have two operands, they will still see the speed-up.

And the speed-up is good, even in these cases. You can compare using the new code:

$ ./python.exe -m timeit -s l=[0,1,2,3] [0,1,2,3]+l  # Hits new branch
5000000 loops, best of 5: 87.9 nsec per loop

$ ./python.exe -m timeit -s l=[0,1,2,3] l+[0,1,2,3]  # Hits old branch
5000000 loops, best of 5: 92.5 nsec per loop
History
Date User Action Args
2019-10-11 18:20:35brandtbuchersetrecipients: + brandtbucher, serhiy.storchaka, pablogsal
2019-10-11 18:20:35brandtbuchersetmessageid: <1570818035.53.0.99455845507.issue38436@roundup.psfhosted.org>
2019-10-11 18:20:35brandtbucherlinkissue38436 messages
2019-10-11 18:20:35brandtbuchercreate