Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
PyList_SetSlice() allows to remove an item by index, as in `del a[i]`. list.remove() searches the item by value and removes the first occurrence. You can implement it via PySequence_Index() and PyList_SetSlice(), but it is more convenient to just call the method. There is no C API for most methods of builtin types. C API is only added for the following cases: 1. Conversion between Python and C values. There is no other way to do this. PyLong_AsLong() and PyLong_FromLong(). 2. Access to general protocols. PyNumber_Add(), PyObject_GetAttr(), PySequence_etc. 3. Specialized versions for concrete types if they are much more convenient and performant. They are also often preceded the more general API. PyObject_GetItem() -> PySequence_GetItem() -> PyList_GetItem() -> PyList_GET_ITEM(). 4. High-level common operations. From PyImport_ImportModule() to PyRun_SimpleString(). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41871> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com