-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-91247: improve performance of list and tuple repeat #32045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
64f74f8 to
109526a
Compare
|
Microbenchmark (main against commit Code for benchmark``` import pyperf runner = pyperf.Runner()setup='a=[1,2,3]; a1=[1,]; t=(1,2,3,4)' for n in [1,2,10,1000]: runner.timeit(name=f"[control] list pop+append", |
MaxwellDupre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
414 tests OK.
1 test failed:
test_embed
I don't think this is related, hence with most test passing looks ok.
|
@MaxwellDupre Thanks for the approval. Note that this PR was marked draft. There are two PRs to resolve #91247, this one and #91482. I have a small preference for #91482 (but this PR is also an improvement) |
|
Closing as #91482 seems a better approach |
Improve the performance of the list repeat methods by reducing the number of reference count operations and copying data using
memcpy. The approach to reduce the number ofmemcpyinvocations is similar to #31999, but due to the handling of reference counts in thelistandtuplerepeat methods the code is slightly different.Note: the specialization for the case of 1 item in a
listortuplecan be removed with (almost) no loss of performance. More details and a comparison against the version with specializations (#91482) are the issue #91247.https://bugs.python.org/issue47091