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-111489: Add PyTuple_FromArray() function by vstinner · Pull Request #139691 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Oct 7, 2025 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: [C API] Make _PyTuple_FromArray() function public #111489

📚 Documentation preview 📚: https://cpython-previews--139691.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

eendebakpt reacted with eyes emoji
All reactions
  • 👀 1 reaction
@vstinner
pythongh-111489: Add PyTuple_FromArray() function
ce1b2ff
@vstinner vstinner added the topic-C-API label Oct 7, 2025
@vstinner
vstinner requested a review from AA-Turner as a code owner October 7, 2025 10:54
@bedevere-app bedevere-app Bot mentioned this pull request Oct 7, 2025
[C API] Make _PyTuple_FromArray() function public #111489
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 7, 2025
@vstinner

vstinner commented Oct 7, 2025

Copy link
Copy Markdown
Member Author

cc @serhiy-storchaka @encukou

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
Add test on empty tuple
b0fbeae
serhiy-storchaka
serhiy-storchaka reviewed Oct 7, 2025
View reviewed changes
Comment thread Lib/test/test_capi/test_tuple.py Resolved

Uh oh!

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

Comment thread Lib/test/test_capi/test_tuple.py Resolved

Uh oh!

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

Comment thread Modules/_testcapi/tuple.c Resolved

Uh oh!

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

Comment thread Modules/_testcapi/tuple.c Resolved

Uh oh!

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

Comment thread Modules/_testcapi/tuple.c Resolved

Uh oh!

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

Comment thread Modules/_testcapi/tuple.c Resolved

Uh oh!

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

Comment thread Doc/c-api/tuple.rst Resolved

Uh oh!

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

@vstinner
Address Serhiy's review
cc47b10
@vstinner

vstinner commented Oct 7, 2025

Copy link
Copy Markdown
Member Author

@serhiy-storchaka: I addressed your comments. Please review the updated PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka
serhiy-storchaka reviewed Oct 7, 2025
View reviewed changes
Comment thread Lib/test/test_capi/test_tuple.py

tup = ()
copy = tuple_fromarray(tup)
self.assertIs(copy, tup)

@serhiy-storchaka serhiy-storchaka Oct 7, 2025

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.

Is not the empty tuple singleton a CPython implementation detail?

Sorry, something went wrong.

Uh oh!

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

All reactions

@vstinner vstinner Oct 7, 2025

Copy link
Copy Markdown
Member Author

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.

The whole file is a CPython implementation detail (_testcapi), no?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/test/test_capi/test_tuple.py Resolved

Uh oh!

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

Comment thread Modules/_testcapi/tuple.c Resolved

Uh oh!

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

Comment thread Objects/tupleobject.c Resolved

Uh oh!

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

@vstinner
Use SystemError for negative size
89f91fc
Use also UNINITIALIZED_SIZE in test code.
@vstinner

vstinner commented Oct 7, 2025

Copy link
Copy Markdown
Member Author

I updated the PR for the latest review.

All reactions

Sorry, something went wrong.

Uh oh!

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

serhiy-storchaka
serhiy-storchaka approved these changes Oct 7, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

LGTM. 👍

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/c-api/tuple.rst
Comment on lines +42 to +43
Create a tuple of *size* items and copy references from *array* to the new
tuple.

@serhiy-storchaka serhiy-storchaka Oct 7, 2025

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.

I would prefer to formulate this in words more similar to PyTuple_New() or PyTuple_Pack() ("Return a new tuple object of size ... "), but this is not so important.

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 Oct 7, 2025
@encukou

encukou commented Oct 7, 2025

Copy link
Copy Markdown
Member

Implementation looks good, thanks! Do you want to open a WG vote for this?

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner mentioned this pull request Oct 7, 2025
Add PyTuple_FromArray() function capi-workgroup/decisions#79
Closed
5 of 6 tasks
@vstinner

vstinner commented Oct 7, 2025

Copy link
Copy Markdown
Member Author

Do you want to open a WG vote for this?

I created capi-workgroup/decisions#79.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 7, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

I exchanged array and size parameters, new API:

PyObject* PyTuple_FromArray(Py_ssize_t size, PyObject *const *array)

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner force-pushed the tuple_fromarray branch from caad089 to 89f91fc Compare October 8, 2025 14:06
@vstinner

vstinner commented Oct 8, 2025

Copy link
Copy Markdown
Member Author

I exchanged array and size parameters, new API: (...)

Sorry, I changed my preference back to (array, size) as before :-) See the API discussion at: capi-workgroup/decisions#79

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 10, 2025

Copy link
Copy Markdown
Member Author

I created capi-workgroup/decisions#79.

The C API Working Group accepted this API.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit e31c22d into python:main Oct 10, 2025
4 checks passed

Uh oh!

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

@vstinner
vstinner deleted the tuple_fromarray branch October 10, 2025 06:54
@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 10, 2025
@vstinner

vstinner commented Oct 10, 2025

Copy link
Copy Markdown
Member Author

Merged. Thanks for your review @serhiy-storchaka and @encukou!

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Oct 14, 2025

Copy link
Copy Markdown
Member Author

I added the function to pythoncapi-compat: python/pythoncapi-compat@89e023e

All reactions

Sorry, something went wrong.

Uh oh!

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

@efimov-mikhail efimov-mikhail mentioned this pull request Oct 28, 2025
[3.14] gh-139951: Tests on tuple tracking (GH-140575) #140701
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

topic-C-API

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.

3 participants

@vstinner @encukou @serhiy-storchaka
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.