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-123471: Make itertools.zip_longest safe in the FT build by eendebakpt · Pull Request #146033 · python/cpython

Conversation

@eendebakpt

@eendebakpt eendebakpt commented Mar 16, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

ziplongest_next is not thread safe due to setting the iterators in lz->ittuple to NULL on exhaustion. In addition, the lz->numactive is mutable state.

The usual approach to making the iterators in this module thread-safe by not setting the underlying iterator to NULL is not working here, since the NULL value is used as a signal (e.g. the check it == NULL). We therefore make the iterator safe using a critical section.

  • Issue: Make concurrent iteration over pairwise, combinations, permutations, cwr, product, etc. from itertools safe under free-threading #123471

Sorry, something went wrong.

Uh oh!

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

All reactions
@eendebakpt
Make itertools.zip_longest safe in the FT build
ac98683
@eendebakpt
eendebakpt requested a review from rhettinger as a code owner March 16, 2026 17:56
@bedevere-app bedevere-app Bot mentioned this pull request Mar 16, 2026
Make concurrent iteration over pairwise, combinations, permutations, cwr, product, etc. from itertools safe under free-threading #123471
Open
@bedevere-app bedevere-app Bot added the awaiting review label Mar 16, 2026
eendebakpt and others added 2 commits March 16, 2026 22:47
@eendebakpt
Merge branch 'main' into ziplongest_ft
1a0ebd9
@blurb-it
📜🤖 Added by blurb_it.
94fd7d7
kumaraditya303
kumaraditya303 approved these changes Mar 18, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Mar 18, 2026
@eendebakpt
Merge branch 'main' into ziplongest_ft
d70e699
@eendebakpt eendebakpt added the topic-free-threading label Mar 21, 2026
@kumaraditya303
kumaraditya303 merged commit 9214e3f into python:main Mar 27, 2026
52 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 27, 2026
@pablogsal pablogsal mentioned this pull request Apr 4, 2026
gh-130273: Fix traceback color output with unicode characters #142529
Merged
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Apr 16, 2026
@eendebakpt @clin1234
pythongh-123471: Make itertools.zip_longest safe in the FT build (p…
a5de7da
…ython#146033)
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@eendebakpt @ljfp
pythongh-123471: Make itertools.zip_longest safe in the FT build (p…
6c33c8a
…ython#146033)
@nascheme nascheme mentioned this pull request Jul 14, 2026
Backport free-threading memory-safety fixes to 3.14 and 3.15 #153714
Closed
nascheme added a commit that referenced this pull request Jul 17, 2026
@nascheme @eendebakpt @kumaraditya303
[3.14] gh-123471: Free-threading fixes for itertools (GH-131212) (GH-…
45bfb43
…132814) (GH-135689) (GH-144402) (GH-146033) (GH-142957) (GH-153791)

Combined backport of PRs from main branch, fixing free-threading data-races in itertools:

* gh-123471: make concurrent iteration over `itertools.cycle` safe under free-threading (gh-131212)
* gh-123471: Make itertools.product and itertools.combinations thread-safe (GH-132814)
* gh-123471: Make itertools.chain thread-safe (gh-135689)
* gh-123471: Make concurrent iteration over `itertools.permutations` and `itertools.combinations_with_replacement` thread-safe (gh-144402)
* gh-123471: make concurrent iteration over itertools.accumulate thread-safe (gh-144486)
* gh-123471: Make `itertools.zip_longest` safe in the FT build (gh-146033)

(cherry picked from commit 26a1cd4)
(cherry picked from commit 847d1c2)
(cherry picked from commit 0533c1f)
(cherry picked from commit 009c8c0)
(cherry picked from commit 3a24856)
(cherry picked from commit 9214e3f)

Co-authored-by: Pieter Eendebak <[email protected]>
Co-authored-by: Kumar Aditya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

topic-free-threading

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.

2 participants

@eendebakpt @kumaraditya303
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 01402520 — 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.