Improve islice_extended memory usage when start<0 and step>0#995
Merged
bbayles merged 2 commits intomore-itertools:masterfrom May 30, 2025
Merged
Conversation
Ensure we release iterated elements asap when start<0 and step>0. We're currently holding a reference on all the elements until we've completed a full iteration. See more-itertools#994 for details.
- previous was partial. cached_item variable was keeping a reference on the current item a bit too long.
Contributor
|
I'm not sure this is how Bo wants to tackle this issue, but that's just what I had in mind Ben. Great stuff - thanks. |
bbayles
approved these changes
May 30, 2025
Collaborator
|
This is fine for this case, thanks for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ensure we release iterated elements as soon as
start<0andstep>0.We're currently holding a reference on all the elements until we've completed a full iteration.
See #994 for a detailed example.
Issue reference
#994
Changes
In this specific case, improved the iteration over the cached data, by also releasing elements after having been yield.
Checks and tests