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-142863: optimize list and set calls with generator expressions by kumaraditya303 · Pull Request #142864 · python/cpython

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Dec 17, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • Issue: optimize list/set calls with generator expression #142863

Sorry, something went wrong.

Uh oh!

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

All reactions
kumaraditya303 added 3 commits December 17, 2025 14:13
@kumaraditya303
optimize for list
3b04c79
@kumaraditya303
optimize for sets
99fb67b
@kumaraditya303
add comment
dcf8950
@bedevere-app bedevere-app Bot mentioned this pull request Dec 17, 2025
optimize list/set calls with generator expression #142863
Closed
kumaraditya303 and others added 3 commits December 17, 2025 15:15
@kumaraditya303
fix test_dis
1c40a6f
@kumaraditya303
Merge branch 'main' into optimize-list-set
6870f1c
@blurb-it
📜🤖 Added by blurb_it.
5ae3557
@kumaraditya303
kumaraditya303 marked this pull request as ready for review December 17, 2025 10:37
@kumaraditya303
kumaraditya303 requested review from ZeroIntensity, ericsnowcurrently, iritkatriel and markshannon as code owners December 17, 2025 10:37
@bedevere-app bedevere-app Bot added the awaiting core review label Dec 17, 2025
@kumaraditya303

kumaraditya303 commented Dec 23, 2025

Copy link
Copy Markdown
Contributor Author

Benchmark results:

Before:

❯ ./python.exe -m timeit "list(x for x in range(10000))"
2000 loops, best of 5: 188 usec per loop
❯ ./python.exe -m timeit "set(x for x in range(10000))"
1000 loops, best of 5: 226 usec per loop

After:

❯ ./python.exe -m timeit "list(x for x in range(10000))"
2000 loops, best of 5: 150 usec per loop
❯ ./python.exe -m timeit "set(x for x in range(10000))"
2000 loops, best of 5: 178 usec per loop
All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
kumaraditya303 requested review from Fidget-Spinner and brandtbucher December 23, 2025 08:17
@markshannon

markshannon commented Dec 23, 2025

Copy link
Copy Markdown
Member

This looks promising.

@kumaraditya303 can you benchmark this with small sequences, as those tend to more common.

@iritkatriel could you take a look, as author of the tuple/any/all optimization.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303

kumaraditya303 commented Dec 23, 2025

Copy link
Copy Markdown
Contributor Author

can you benchmark this with small sequences, as those tend to more common.

Benchmark with smaller sequence:
Before:

❯ ./python.exe -m timeit "list(x for x in range(25))" 
500000 loops, best of 5: 483 nsec per loop

After:

 ❯ ./python.exe -m timeit "list(x for x in range(25))" 
500000 loops, best of 5: 390 nsec per loop 
All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
Merge branch 'main' of https://github.com/python/cpython into optimiz…
2dbe6fc
…e-list-set
@kumaraditya303

kumaraditya303 commented Jan 5, 2026

Copy link
Copy Markdown
Contributor Author

@markshannon I have fixed the merge conflicts, can you review this?

All reactions

Sorry, something went wrong.

Uh oh!

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

markshannon
markshannon approved these changes Jan 6, 2026
View reviewed changes

@markshannon markshannon 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.

Looks good. Thanks.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jan 6, 2026
@kumaraditya303
kumaraditya303 merged commit 74bb3ca into python:main Jan 6, 2026
50 checks passed

Uh oh!

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

@kumaraditya303
kumaraditya303 deleted the optimize-list-set branch January 6, 2026 17:53
@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 6, 2026
@kumaraditya303 kumaraditya303 mentioned this pull request Jan 13, 2026
Broader specialization in the Specializing Adaptive Interpreter for better JIT performance #143732
Open
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@kumaraditya303 @thunder-coding
pythongh-142863: optimize list and set calls with generator expre…
916f287
…ssions (python#142864)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon markshannon approved these changes
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity is a code owner
@iritkatriel iritkatriel Awaiting requested review from iritkatriel iritkatriel is a code owner
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner
@brandtbucher brandtbucher Awaiting requested review from brandtbucher

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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

@kumaraditya303 @markshannon
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.