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

2019-10-11 Thread Armin Rigo
Change by Armin Rigo : -- nosy: -arigo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

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

2019-10-11 Thread Brandt Bucher
Change by Brandt Bucher : -- pull_requests: +16298 pull_request: https://github.com/python/cpython/pull/16705 ___ Python tracker ___ ___

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

2019-10-10 Thread Brandt Bucher
Change by Brandt Bucher : -- pull_requests: -16290 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

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

2019-10-10 Thread Brandt Bucher
Change by Brandt Bucher : -- pull_requests: +16290 pull_request: https://github.com/python/cpython/pull/16705 ___ Python tracker ___ ___

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

2019-03-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: Everyone, thanks for chiming in. Will mark this as closed/rejected. For this reasons listed this thread, it isn't a sensible path for us (hairy at best, flat-out wrong at worst). To the extent people ever have quadratic behavior problem, we already hav

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

2019-03-13 Thread Tim Peters
Tim Peters added the comment: Josh, I agree - but do read Armin's response. The string hack was done inside ceval.c, where we have extraordinary knowledge of context. Adding similar hacks inside Python C API functions seems to be a non-starter - they can't magically start mutating argument

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

2019-03-13 Thread Josh Rosenberg
Josh Rosenberg added the comment: I believe Tim Peters's concern with: Set1 = Set1 & Set2 is misplaced, because he's drawn an analogy with the string concatenation optimization, which *does* handle: Str1 = Str1 + Str2 because the optimization is in the ceval loop and can check the

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

2019-03-13 Thread Josh Rosenberg
Josh Rosenberg added the comment: Raymond said: "FWIW, the non-operator versions of these operations already support passing in multiple arguments and is the preferred way to do it." True for sets with union/intersection/difference (and their inplace equivalents), but not for lists and bytea

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

2019-03-13 Thread Armin Rigo
Armin Rigo added the comment: ...or PySequence_Concat() instead of PyNumber_Add(); same reasoning. -- ___ Python tracker ___ ___ Py

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

2019-03-13 Thread Armin Rigo
Armin Rigo added the comment: This patch is based on the following reasoning: if 'a' is a list and the reference count of 'a' is equal to 1, then we can mutate in-place 'a' in a call to 'a->ob_type->tp_as_sequence->list_concat'. Typically that is called from 'PyNumber_Add(a, b)'. The patch

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

2019-03-13 Thread Tim Peters
Tim Peters added the comment: Serhiy, if I understand this, it _could_ pay big with even just a few operations. For example, [0] * 100 + [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

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

2019-03-13 Thread Brandt Bucher
Change by Brandt Bucher : -- title: Linear-time list, set, and bytearray ops. -> Avoid unnecessary copies for list, set, and bytearray ops. ___ Python tracker ___