[issue38436] Improved performance for list addition.

Serhiy Storchaka report at bugs.python.org
Fri Oct 11 14:43:44 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

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

Because the time includes the time of iterating, which can be significant in comparison with adding two integers. Please use the pyperf module with --duplicate=1000.

> 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).

Could you provide any numbers? For example you can patch ceval.c to count these BINARY_ADD for which your optimization works and these for which it does not work and output counts at the exit of Python. Run several Python programs with the modified interpreter. Tests are bad example, but better than nothing. Something like hg would be better. You are free to find programs that would benefit the most from your optimization.

> And the speed-up is good, even in these cases.

5%. It is not impressive for optimizing a single rare operation.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38436>
_______________________________________


More information about the Python-bugs-list mailing list