Improve islice_extended memory usage when stop<0 and step>0#999
Merged
bbayles merged 2 commits intomore-itertools:masterfrom Jun 27, 2025
Merged
Conversation
Ensure we release iterated elements asap when stop<0 and step>0. We're currently holding a reference on that last returned element one iteration step too long, since we use a variable to hold the yielded element. - Improved _islice_helper for start>0,stop<0,step>0. - Updated unit test test_elements_lifecycle with improvement.
eab2b81 to
addb37f
Compare
- improvement has been introduced in previous commit. - removing comments in a separate commit just for diff readability.
addb37f to
1a789ff
Compare
Contributor
Author
|
Addresses following issue: |
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.
Issue reference
#1011
Follow up on issue #994
Scope
Improve
islice_extendedmemory usage whenstop<0andstep>0This pull request cover the case when
stop<0andstep>0where we're currently holding a reference on that returned element one iteration step too long, since we store the yielded element in a temporary variable.start<0andstep>0was covered with #995 (improvement) and #996 (unit test)Changes
islice_extendedwhenstop<0andstep>0.Checks and tests
On
python 3.13