[issue36229] Avoid unnecessary copies for list, set, and bytearray ops.

Tim Peters report at bugs.python.org
Wed Mar 13 14:51:19 EDT 2019


Tim Peters <tim at python.org> added the comment:

Serhiy, if I understand this, it _could_ pay big with even just a few operations.  For example,

    [0] * 1000000 + [1] + [2] + [3]
    
As-is, we'll copy the million zeroes three times.  WIth the patch, more likely the original vector of a million zeroes would be extended in-place, three times with a single element each time.

But I don't know that people do that in real code.  It would be great to find real examples in real could that would benefit.

----------

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


More information about the Python-bugs-list mailing list