bpo-34152: Improved performance of list for a[::-1] = a, a[i:j] = a and a[len(a):] = b.#8333
bpo-34152: Improved performance of list for a[::-1] = a, a[i:j] = a and a[len(a):] = b.#8333sir-sigurd wants to merge 4 commits intopython:masterfrom
Conversation
…nd a[len(a):] = b.
pablogsal
left a comment
There was a problem hiding this comment.
Some comments here but I am not sure how i feel about this, as the code is much more complex only for these special cases. Specially the case for a[i:j] = a can be a bit confusing if you don't see before hand the operation strategy.
| size_t s; | ||
| int result = -1; /* guilty until proved innocent */ | ||
|
|
||
| if (ilow < 0) |
|
|
||
| if (ilow < 0) | ||
| ilow = 0; | ||
| else if (ilow >= Py_SIZE(a)) |
There was a problem hiding this comment.
Use braces here (see previous message).
| else if (ilow >= Py_SIZE(a)) | ||
| ilow = Py_SIZE(a); | ||
|
|
||
| if (ihigh < ilow) |
There was a problem hiding this comment.
Use braces here (see previous message).
|
|
||
| if (ihigh < ilow) | ||
| ihigh = ilow; | ||
| else if (ihigh > Py_SIZE(a)) |
There was a problem hiding this comment.
Use braces here (see previous message).
| for (k = 0; k < ilow; k++) { | ||
| PyObject *obj = a->ob_item[k]; | ||
| Py_INCREF(obj); | ||
| a->ob_item[k + ilow] = obj; |
There was a problem hiding this comment.
Nitpick: I prefer a->ob_item[ilow + k] = obj; as I always tend to read this as point_of_origin + moving_index . Also is consistent with the rest of the movements.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Closed: see https://bugs.python.org/issue34152 for rationale. Thanks for the proposal! |
https://bugs.python.org/issue34152