Performance of repeat and inplace repeat operations. #325
Unanswered
eendebakpt
asked this question in
Q&A
Replies: 1 comment 1 reply
-
It's not so easy for list/tuple, because their contents has refcounts that need to be updated. So probably there's less opportunity for improvement. (Feel free to submit a PR with measurements to prove me wrong though!) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In a recent PR the performance of the repeat and inplace repeat methods was improved for the
bytearray
object (python/cpython#31856) by reducing the number ofmemcpy
operations.In python/cpython#31999 the same approach is used to improve the performance of
array_inplace_repeat
. In that PR some of the code is refactored into utility methods_PyBytes_Repeat
and_PyBytes_RepeatInPlace
. The code is faster for a high number of repeats, but for a lower number of repeats this is not clear (microbenchmarks on my system don't give answers). Perhaps there is some overhead in calling the utility functions.The list and tuple objects also have repeat methods, but they do not use the
memcpy
operation.In python/cpython@main...eendebakpt:performance/list_repeat a small improvement is made, but perhaps more can be gained by using the utility methods..
memcpy
has a overhead on those.Any thoughts or suggestions are welcome.
@sweeneyde
Beta Was this translation helpful? Give feedback.
All reactions