Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Dec 17, 2025

@kumaraditya303
Copy link
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

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

@kumaraditya303
Copy link
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 

@kumaraditya303
Copy link
Contributor Author

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

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

@kumaraditya303 kumaraditya303 merged commit 74bb3ca into python:main Jan 6, 2026
50 checks passed
@kumaraditya303 kumaraditya303 deleted the optimize-list-set branch January 6, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants