GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-98363: Add itertools.batched() by rhettinger · Pull Request #98364 · python/cpython

Conversation

@rhettinger

@rhettinger rhettinger commented Oct 17, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Add itertools.batched() #98363

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rhettinger added 10 commits October 16, 2022 20:03
@rhettinger
First draft
057390d
@rhettinger
.
047c441
@rhettinger
Fix NULL test
9061042
@rhettinger
Improve the docstring and add the regular docs
72a03c6
@rhettinger
.
21a6f67
@rhettinger
Add tests
61b83df
@rhettinger
Add entry to toplevel table in the docs
93bf013
@rhettinger
Remove bogus decref
eb6949c
@rhettinger
Flatten before joining
7fd4016
@rhettinger
Add blurb
8fb8bdf
@rhettinger rhettinger added type-feature A feature request or enhancement 3.12 only security fixes labels Oct 17, 2022
@bedevere-bot bedevere-bot added the awaiting core review label Oct 17, 2022
@rhettinger
Add motivating use case and make equivalent code more accurate
2b994a3
JelleZijlstra
JelleZijlstra reviewed Oct 17, 2022
View reviewed changes

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

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.

I agree with adding this, just a few small comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_itertools.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/itertoolsmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/itertoolsmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

rhettinger and others added 11 commits October 17, 2022 13:11
@rhettinger
Remove TODO comment
fa9c306
@rhettinger @JelleZijlstra
Update Lib/test/test_itertools.py
c49fb17
Co-authored-by: Jelle Zijlstra <[email protected]>
@rhettinger
Merge branch 'main' into itertools_batched
3fbc9c5
@rhettinger
Neaten-up
4c25341
@rhettinger
Make the example more self-explanatory
41acb45
@rhettinger
Test pure python equivalent
77de77c
@rhettinger
Test pure python equivalent
7390670
@rhettinger
Add GC test
c836bc7
@rhettinger
Add "TestVariousIteratorArgs" tests
c0ca79d
@rhettinger
Fix test case I()
8238c28
@rhettinger
Remove development note
b9cbb46
@rhettinger rhettinger added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 17, 2022
@bedevere-bot

bedevere-bot commented Oct 17, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @rhettinger for commit b9cbb46 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 17, 2022
@rhettinger
Remove docstring from pure Python equivalent.
4799e6a
TeamSpen210
TeamSpen210 reviewed Oct 17, 2022
View reviewed changes
Comment thread Doc/library/itertools.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

sweeneyde
sweeneyde reviewed Oct 17, 2022
View reviewed changes
Comment thread Modules/itertoolsmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@rhettinger
Fix missing argument in the docs table entry.
bac2f6c
@rhettinger
rhettinger merged commit de3ece7 into python:main Oct 17, 2022
@bedevere-bot bedevere-bot removed the awaiting core review label Oct 17, 2022
gvanrossum
gvanrossum reviewed Oct 23, 2022
View reviewed changes
Comment thread Doc/library/itertools.rst
Roughly equivalent to::

def batched(iterable, n):
# batched('ABCDEFG', 3) --> ABC DEF G

@gvanrossum gvanrossum Oct 23, 2022

Copy link
Copy Markdown
Member

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"?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anderssonjohan reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@anderssonjohan anderssonjohan Oct 25, 2022

Copy link
Copy Markdown

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.

Suggested change
# batched('ABCDEFG', 3) --> ABC DEF G
# list(batched('ABCDEFG', 3)) --> [['A', 'B', 'C'], ['D', 'E', 'F'], ['G']]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lgeiger lgeiger mentioned this pull request Nov 1, 2024
Simplify stdlib code by using itertools.batched() #126317
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra left review comments
@gvanrossum gvanrossum gvanrossum left review comments
@sweeneyde sweeneyde sweeneyde left review comments
+2 more reviewers
@anderssonjohan anderssonjohan anderssonjohan left review comments
@TeamSpen210 TeamSpen210 TeamSpen210 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

3.12 only security fixes type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@rhettinger @bedevere-bot @anderssonjohan @JelleZijlstra @gvanrossum @TeamSpen210 @sweeneyde
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.