Skip to content

Optimize windowed itertool#810

Merged
bbayles merged 7 commits intomore-itertools:masterfrom
james-wasson:windowed
Mar 14, 2024
Merged

Optimize windowed itertool#810
bbayles merged 7 commits intomore-itertools:masterfrom
james-wasson:windowed

Conversation

@james-wasson
Copy link
Copy Markdown
Contributor

Issue reference

#809

Changes

I have been working towards increasing the performance of the windowed method and have made some good headway. Main performance gains come from using built in itertools methods and using islice to "fast forward" the windows.

Making line length shorter

Remove erronious inclusion of old method
@bbayles
Copy link
Copy Markdown
Collaborator

bbayles commented Feb 20, 2024

I'm -0 on this one - the better performance for larger size inputs is good, but I'm not sure if the extra complexity is worth it.

@james-wasson
Copy link
Copy Markdown
Contributor Author

I can test out the performance of the single non-overlapping branch but I really do think non initializing a deque if possible is the way to go here. I will see if I can optimize further.

@james-wasson
Copy link
Copy Markdown
Contributor Author

james-wasson commented Mar 13, 2024

Newest changes improve every metric minorly anywhere from 0-40% speed up over base code. Not huge but considering this is one of the most widely used methods and is used all over this code base as well it should provide a nice bonus.

See the issue (#809) for new metrics

@bbayles
Copy link
Copy Markdown
Collaborator

bbayles commented Mar 14, 2024

Thanks for the analysis. I'll take this PR if you can revert the change to the argument names?

@james-wasson
Copy link
Copy Markdown
Contributor Author

@bbayles Done, I will avoid changing argument names in the future. Thanks!

@bbayles bbayles merged commit 4c7e4e2 into more-itertools:master Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants