[issue36229] Linear-time list, set, and bytearray ops.

Raymond Hettinger report at bugs.python.org
Tue Mar 12 16:45:26 EDT 2019


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

> Binary operations on collections are, in general, of quadratic complexity.

BTW, this seems like drastic mischaracterization, making it seem like something is wrong with the containers.  It is more accurate to say that an uncommon user pattern of repeated copy-and-add operations on containers can give quadratic behavior.

Likewise, it is a mischaracterization to say this PR "fixes" the containers.  Instead, it uses what is arguably a hack to recognize potential cases where the copy step can be skipped, even though that is what the user explicitly specified should occur.

Armin, do you remember the outcome of the discussions when you added the string optimization for repeated concatenation.  I do remember that we told users not to rely on it and that the str.join() was still the recommended best practice.

----------
nosy: +arigo

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


More information about the Python-bugs-list mailing list