-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
GH-98363: Add itertools.batched() #98364
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
057390d
First draft
rhettinger 047c441
.
rhettinger 9061042
Fix NULL test
rhettinger 72a03c6
Improve the docstring and add the regular docs
rhettinger 21a6f67
.
rhettinger 61b83df
Add tests
rhettinger 93bf013
Add entry to toplevel table in the docs
rhettinger eb6949c
Remove bogus decref
rhettinger 7fd4016
Flatten before joining
rhettinger 8fb8bdf
Add blurb
rhettinger 2b994a3
Add motivating use case and make equivalent code more accurate
rhettinger fa9c306
Remove TODO comment
rhettinger c49fb17
Update Lib/test/test_itertools.py
rhettinger 3fbc9c5
Merge branch 'main' into itertools_batched
rhettinger 4c25341
Neaten-up
rhettinger 41acb45
Make the example more self-explanatory
rhettinger 77de77c
Test pure python equivalent
rhettinger 7390670
Test pure python equivalent
rhettinger c836bc7
Add GC test
rhettinger c0ca79d
Add "TestVariousIteratorArgs" tests
rhettinger 8238c28
Fix test case I()
rhettinger b9cbb46
Remove development note
rhettinger 4799e6a
Remove docstring from pure Python equivalent.
rhettinger bac2f6c
Fix missing argument in the docs table entry.
rhettinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2022-10-17-12-49-02.gh-issue-98363.aFmSP-.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Added itertools.batched() to batch data into lists of a given length with | ||
the last list possibly being shorter than the others. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Maybe tweak the example so it cannot be misunderstood as "return 3 batches"?
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.