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 — Add itertools.batched() · Issue #98363 · python/cpython

Add itertools.batched() #98363

New issue
Copy link
New issue
Copy link
Closed
Closed
Add itertools.batched()#98363
Copy link
Assignees
rhettinger
Labels
3.12only security fixesonly security fixestype-featureA feature request or enhancementA feature request or enhancement

Description

@rhettinger
rhettinger
opened on Oct 17, 2022
Issue body actions

This was requested on python-ideas:

  def batched(iterable, n):
      "Batch data into lists of length n. The last batch may be shorter."
      # batched('ABCDEFG', 3) --> ABC DEF G
      if n < 1:
          raise ValueError('n must be >= 1')
      it = iter(iterable)
      while (batch := list(islice(it, n))):
          yield batch

Linked PRs

  • GH-98363: Have batched() return tuples #100118
  • GH-98363: Shrink the physical size as well as the logical size #100138
  • [3.11] GH-98363: Update batched() recipe in docs to match 3.12 #100323
Reacted by Rajarishi Devarajan, Sebastian Linke, Seyed Mahdi Moosavi, Alex Waygood, AmirSoroush, Furkan Onder, Andres G. Delannoy, Ivan Nazarov, Mike Nelhams, Bartosz Sławecki and 1 more
Reacted by Rickard Cardell, Alexander Overvoorde, Caleb Hattingh, Jonathan Striebel, f2koi, Mike Nelhams, Håkon V. Treider and Michael Maxwell

Activity

  1. rhettinger
    added
    type-featureA feature request or enhancementA feature request or enhancement
    3.12only security fixesonly security fixes
    on Oct 17, 2022
  2. rhettinger
    self-assigned this
    on Oct 17, 2022
  3. rhettinger
    added a commit that references this issue on Oct 17, 2022

    GH-98363: Add itertools.batched() (GH-98364)

    de3ece7
  4. rhettinger
    closed this as completedon Oct 17, 2022
  5. rhettinger
    added a commit that references this issue on Oct 20, 2022

    GH-98363: Presize the list for batched() (GH-98419)

    c1e02d4
  6. carljm
    added a commit that references this issue on Oct 20, 2022

    Merge branch 'main' into typewatch

    8bba5da
  7. rhettinger
    added 4 commits that reference this issue on Oct 21, 2022

    GH-98363: Fix exception handling in batched() (GH-98523)

    a5ff80c

    GH-98363: Use better accessor macro (#98535)

    8d57423

    pythonGH-98363: Slicing isn't necessary. A resize will suffice.

    7c890ed

    GH-98363: Slicing isn't necessary. A size reduction will suffice. (GH…

    5871e19
  8. rhettinger
    added 3 commits that reference this issue on Dec 8, 2022

    GH-98363: Have batched() return tuples (GH-100118)

    35cc0ea

    pythonGH-98363: Shrink the physical size as well as the logical size

    82c4d55

    GH-98363: Shrink the physical size as well as the logical size (GH-10…

    8c21546
  9. rhettinger
    added a commit that references this issue on Dec 18, 2022

    [3.11] GH-98363: Update batched() recipe in docs to match 3.12 (#100323)

    0918667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rhettinger
    rhettinger

Labels

3.12only security fixesonly security fixestype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.