You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently for C extension devs if they over-allocate a list, and then realize later in a loop after checking using some if's that not every entry is filled and some of them as NULL one might want to directly call the api function to remove any and every item inside the list object that is still NULL. I have looked inside the code and noticed that the same implementation for list.removein the python code side can be reused for this without issues and as such should be a minor change except for the new api function that would be added to the public api and export from pythonXY.dll/pythonXY.so/pythonXY.dylib.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered:
vstinner
changed the title
[Enhancement] Expose List.Remove as PyList_Remove(PyObject *) in the C API.
[Enhancement] Expose list.remove() as PyList_Remove(PyObject *) in the C API.
May 20, 2024
ISTM that the C API should remain low level for two reasons.
There is already an API for C code to call anything that can be called from pure python. It adds a tiny amount of overhead but that only matters for fine-grained functions that tend to be called in a loop. Course grained functions that are already O(n) don't see any real benefit.
Almost the entire point of writing C code is that you want something different than what pure python gives you. For the most part, you want a low-level API so you can efficiently implement your own customizations (for example, remove-variants that return a flag rather than raising an exception, a single-pass multi-remove, or a right-to-left remove).
Proposal:
Currently for C extension devs if they over-allocate a list, and then realize later in a loop after checking using some if's that not every entry is filled and some of them as
NULL
one might want to directly call the api function to remove any and every item inside the list object that is stillNULL
. I have looked inside the code and noticed that the same implementation forlist.remove
in the python code side can be reused for this without issues and as such should be a minor change except for the new api function that would be added to the public api and export frompythonXY.dll
/pythonXY.so
/pythonXY.dylib
.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: