Skip to content
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

[C API] Make _PyList_FromArraySteal() function public #111489

Closed
vstinner opened this issue Oct 30, 2023 · 5 comments
Closed

[C API] Make _PyList_FromArraySteal() function public #111489

vstinner opened this issue Oct 30, 2023 · 5 comments

Comments

@vstinner
Copy link
Member

vstinner commented Oct 30, 2023

I dislike PyList_New() + PyList_SET_ITEM() API since the list is immediately tracked by the GC and so calling gc.get_objects() can expose an invalid list object (ex: calling repr(list) can crash). See:

The internal PyObject * _PyList_FromArraySteal(PyObject *const *src, Py_ssize_t n) function should be made public. But it should be renamed to avoid misleading "Steal" term: ownership is "moved" or "transfered", not "stolen".

cc @erlend-aasland

Linked PRs

@vstinner
Copy link
Member Author

We should also make PyObject* _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n) public.

@encukou
Copy link
Member

encukou commented Oct 30, 2023

Can you wait until the new guidelines are approved? Not everyone is happy with the term steal.

@vstinner
Copy link
Member Author

Can you wait until the new guidelines are approved?

The name is discussed at capi-workgroup/problems#11 (comment)

@vstinner
Copy link
Member Author

Naming is discussed at capi-workgroup/api-evolution#25

vstinner added a commit to vstinner/cpython that referenced this issue Dec 11, 2023
Add new functions to create tuple and list from arrays:

* PyTuple_FromArray().
* PyTuple_FromArrayMoveRef().
* PyList_FromArrayMoveRef().

Add tests on new functions.
vstinner added a commit to vstinner/cpython that referenced this issue Dec 11, 2023
Add new functions to create tuple and list from arrays:

* PyTuple_FromArray().
* PyTuple_FromArrayMoveRef().
* PyList_FromArrayMoveRef().

Add tests on new functions.
vstinner added a commit to vstinner/cpython that referenced this issue Dec 11, 2023
Add new functions to create tuple and list from arrays:

* PyTuple_FromArray().
* PyTuple_FromArrayMoveRef().
* PyList_FromArrayMoveRef().

Add tests on new functions.
vstinner added a commit to vstinner/cpython that referenced this issue Dec 11, 2023
Add new functions to create tuple and list from arrays:

* PyTuple_FromArray().
* PyTuple_FromArrayMoveRef().
* PyList_FromArrayMoveRef().

Add tests on new functions.
@vstinner
Copy link
Member Author

@encukou:

Can you wait until the new guidelines are approved?

Ok, I close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants