Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
GH-140052: Add PyTuple_MakeSingle and PyTuple_MakePair#140132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-140052: Add PyTuple_MakeSingle and PyTuple_MakePair #140132
Uh oh!
There was an error while loading. Please reload this page.
Conversation
sergey-miryanov commented Oct 14, 2025 • edited by github-actions bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by github-actions bot
Uh oh!
There was an error while loading. Please reload this page.
Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
sergey-miryanov commented Oct 14, 2025
@vstinner I have made requested changes. Please take a look. |
Uh oh!
There was an error while loading. Please reload this page.
sergey-miryanov commented Oct 14, 2025
Done, please take a look. |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
sergey-miryanov commented Oct 15, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Microbenchmarks: Ubuntu 24.04, gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, same cpu, built with lto enabled t - PyTuple_New + PyTuple_SetItem Microbenchmarks - sergey-miryanov@07f7c6a run scripts
|
eendebakpt commented Oct 21, 2025
In the microbenchmarks it seems odd that |
Uh oh!
There was an error while loading. Please reload this page.
sergey-miryanov commented Oct 23, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Microbenchmark results from Windows machine (Windows 11, i5-11600K @ 3.90GHz) Results for Tuple(EmptyTuple) and Tuple(EmptyTuple, EmptyTuple) - tuple will be tracked (EmptyTuple - is a special case - we don't allocate it) Notes:
Linux benchmarks will be a bit later. Benchmarks here - https://github.com/sergey-miryanov/cpython/tree/140052-pytuple-make-pair-bench |
vstinner commented Oct 23, 2025
I don't know how to read your benchmark. What are the "a", "p", "s", etc. columns? |
vstinner commented Oct 23, 2025
Oh, I suppose that letters are the same from previous benchmark: #140132 (comment) |
sergey-miryanov commented Oct 23, 2025
Yes, they are the same (except
|
sergey-miryanov commented Oct 24, 2025
Microbenchmark results from Linux (Ubuntu 24.04, gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, i5-11600K @ 3.90GHz) Results for Tuple(EmptyTuple) and Tuple(EmptyTuple, EmptyTuple): Notes:
Legend:
|
sergey-miryanov commented Oct 24, 2025
@eendebakpt I have updated microbenchmarks. Could you please take a look? Are they fair enough now? |
sergey-miryanov commented Oct 24, 2025
@vstinner This is ready for review. Could you please take a look? |
| # because we only check type for gc support can't untrack tuple of | ||
| # immutable tuples, see maybe_tracked | ||
| self.assertTrue(gc.is_tracked(make_single((1, 2)))) |
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.
IMO, it'll be better not to check this, since we can make another decision in the future.
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.
We have a small disagreement here.
I think we should explicitly fix the current behavior in the tests.
@efimov-mikhail does not want to fix the behavior that may change in the near future because doing so would require changes to the tests.
We need another opinion on this.
eendebakpt commented Oct 25, 2025
The benchmarks seem fine, although I still find the results surprising (why is But I am +1 on the PR, even if we don't go looking into tiny performance details: the methods |
vstinner commented Oct 28, 2025
I created capi-workgroup/decisions#84 decision issue for the C API Working Group. |
sergey-miryanov commented Nov 17, 2025
Close according capi-workgroup/decisions#84 decision. |
As requested by @vstinner I have added a separate PR with two functions:
PyTuple_MakeSingleandPyTuple_MakePair.📚 Documentation preview 📚: https://cpython-previews--140132.org.readthedocs.build/