Index: Include/listobject.h =================================================================== --- Include/listobject.h (revision 74276) +++ Include/listobject.h (working copy) @@ -53,6 +53,7 @@ PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); +PyAPI_FUNC(int) PyList_APPEND(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); PyAPI_FUNC(int) PyList_Sort(PyObject *); Index: Objects/listobject.c =================================================================== --- Objects/listobject.c (revision 74276) +++ Objects/listobject.c (working copy) @@ -288,6 +288,17 @@ return -1; } +int +PyList_APPEND(PyObject *op, PyObject *newitem) +{ + Py_ssize_t n = PyList_GET_SIZE(self); + + if (list_resize(op, n+1) == -1) + return -1; + + PyList_SET_ITEM(op, n, newitem); +} + /* Methods */ static void Index: Doc/c-api/list.rst =================================================================== --- Doc/c-api/list.rst (revision 74276) +++ Doc/c-api/list.rst (working copy) @@ -108,8 +108,18 @@ Append the object *item* at the end of list *list*. Return ``0`` if successful; return ``-1`` and set an exception if unsuccessful. Analogous to ``list.append(item)``. + +.. cfunction:: int PyList_APPEND(PyObject *list, PyObject *item) + Append the object *item* at the end of list *list*. Return ``0`` if + successful; return ``-1`` and set an exception if unsuccessful. + + .. note:: + + This function "steals" a reference to *item*, and, unlike + :cfunc:`PyList_Append`, does *not* do any type checking. + .. cfunction:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high) Return a list of the objects in *list* containing the objects *between* *low*