cpython/Doc/c-api/list.rst

145 lines
4.6 KiB
ReStructuredText
Raw Normal View History

.. highlight:: c
2008-01-20 05:30:57 -04:00
.. _listobjects:
List Objects
------------
.. index:: object: list
.. c:type:: PyListObject
2008-01-20 05:30:57 -04:00
This subtype of :c:type:`PyObject` represents a Python list object.
2008-01-20 05:30:57 -04:00
.. c:var:: PyTypeObject PyList_Type
2008-01-20 05:30:57 -04:00
This instance of :c:type:`PyTypeObject` represents the Python list type.
This is the same object as :class:`list` in the Python layer.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_Check(PyObject *p)
2008-01-20 05:30:57 -04:00
Return true if *p* is a list object or an instance of a subtype of the list
type. This function always succeeds.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_CheckExact(PyObject *p)
2008-01-20 05:30:57 -04:00
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
Return true if *p* is a list object, but not an instance of a subtype of
the list type. This function always succeeds.
2008-01-20 05:30:57 -04:00
.. c:function:: PyObject* PyList_New(Py_ssize_t len)
2008-01-20 05:30:57 -04:00
Return a new list of length *len* on success, or ``NULL`` on failure.
2008-01-20 05:30:57 -04:00
.. note::
If *len* is greater than zero, the returned list object's items are
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
set to ``NULL``. Thus you cannot use abstract API functions such as
:c:func:`PySequence_SetItem` or expose the object to Python code before
setting all items to a real object with :c:func:`PyList_SetItem`.
2008-01-20 05:30:57 -04:00
.. c:function:: Py_ssize_t PyList_Size(PyObject *list)
2008-01-20 05:30:57 -04:00
.. index:: builtin: len
Return the length of the list object in *list*; this is equivalent to
``len(list)`` on a list object.
.. c:function:: Py_ssize_t PyList_GET_SIZE(PyObject *list)
2008-01-20 05:30:57 -04:00
Similar to :c:func:`PyList_Size`, but without error checking.
2008-01-20 05:30:57 -04:00
.. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
2008-01-20 05:30:57 -04:00
Return the object at position *index* in the list pointed to by *list*. The
position must be non-negative; indexing from the end of the list is not
supported. If *index* is out of bounds (<0 or >=len(list)),
return ``NULL`` and set an :exc:`IndexError` exception.
2008-01-20 05:30:57 -04:00
.. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
2008-01-20 05:30:57 -04:00
Similar to :c:func:`PyList_GetItem`, but without error checking.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)
2008-01-20 05:30:57 -04:00
Set the item at index *index* in list to *item*. Return ``0`` on success.
If *index* is out of bounds, return ``-1`` and set an :exc:`IndexError`
exception.
2008-01-20 05:30:57 -04:00
.. note::
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
This function "steals" a reference to *item* and discards a reference to
an item already in the list at the affected position.
2008-01-20 05:30:57 -04:00
.. c:function:: void PyList_SET_ITEM(PyObject *list, Py_ssize_t i, PyObject *o)
2008-01-20 05:30:57 -04:00
Macro form of :c:func:`PyList_SetItem` without error checking. This is
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
normally only used to fill in new lists where there is no previous content.
2008-01-20 05:30:57 -04:00
.. note::
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
This macro "steals" a reference to *item*, and, unlike
:c:func:`PyList_SetItem`, does *not* discard a reference to any item that
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
is being replaced; any reference in *list* at position *i* will be
leaked.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item)
2008-01-20 05:30:57 -04:00
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
Insert the item *item* into list *list* in front of index *index*. Return
``0`` if successful; return ``-1`` and set an exception if unsuccessful.
Analogous to ``list.insert(index, item)``.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_Append(PyObject *list, PyObject *item)
2008-01-20 05:30:57 -04:00
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
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)``.
2008-01-20 05:30:57 -04:00
.. c:function:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
2008-01-20 05:30:57 -04:00
Return a list of the objects in *list* containing the objects *between* *low*
and *high*. Return ``NULL`` and set an exception if unsuccessful. Analogous
to ``list[low:high]``. Indexing from the end of the list is not supported.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist)
2008-01-20 05:30:57 -04:00
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
Set the slice of *list* between *low* and *high* to the contents of
*itemlist*. Analogous to ``list[low:high] = itemlist``. The *itemlist* may
be ``NULL``, indicating the assignment of an empty list (slice deletion).
Return ``0`` on success, ``-1`` on failure. Indexing from the end of the
list is not supported.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_Sort(PyObject *list)
2008-01-20 05:30:57 -04:00
Merged revisions 71920-71923,71925-71929,71931-71934,71937 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r71920 | jeroen.ruigrok | 2009-04-25 21:44:55 +0200 (za, 25 apr 2009) | 5 lines Issue #4129: More documentation pointers about int -> Py_ssize_t. Also fix up the documentation for PyObject_GC_Resize(). It seems that since it first got documented, the documentation was actually for _PyObject_GC_Resize(). ........ r71921 | jeroen.ruigrok | 2009-04-25 21:46:19 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Documentation notes for int -> Py_ssize_t changes. ........ r71922 | jeroen.ruigrok | 2009-04-25 21:49:05 +0200 (za, 25 apr 2009) | 2 lines Reformat, since I've been busy here anyway. ........ r71923 | jeroen.ruigrok | 2009-04-25 21:54:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: Add a versionchanged notice for a few forgotten entries. ........ r71925 | jeroen.ruigrok | 2009-04-25 22:37:39 +0200 (za, 25 apr 2009) | 2 lines Since it's a macro, actually refer to it as such instead of function. ........ r71926 | jeroen.ruigrok | 2009-04-25 22:40:10 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71927 | jeroen.ruigrok | 2009-04-25 22:41:40 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71928 | jeroen.ruigrok | 2009-04-25 22:43:30 +0200 (za, 25 apr 2009) | 2 lines Reformat prior to editing. ........ r71929 | jeroen.ruigrok | 2009-04-25 22:44:58 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71931 | jeroen.ruigrok | 2009-04-25 22:50:27 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: int -> Py_ssize_t documentation. ........ r71932 | jeroen.ruigrok | 2009-04-25 22:55:39 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71933 | jeroen.ruigrok | 2009-04-25 22:58:35 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: more int -> Py_ssize_t documentation. ........ r71934 | jeroen.ruigrok | 2009-04-25 23:02:34 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: field changed from int to Py_ssize_t. ........ r71937 | jeroen.ruigrok | 2009-04-25 23:16:05 +0200 (za, 25 apr 2009) | 2 lines Issue #4129: document int -> Py_ssize_t changes. ........
2009-04-27 02:43:17 -03:00
Sort the items of *list* in place. Return ``0`` on success, ``-1`` on
failure. This is equivalent to ``list.sort()``.
2008-01-20 05:30:57 -04:00
.. c:function:: int PyList_Reverse(PyObject *list)
2008-01-20 05:30:57 -04:00
Reverse the items of *list* in place. Return ``0`` on success, ``-1`` on
failure. This is the equivalent of ``list.reverse()``.
.. c:function:: PyObject* PyList_AsTuple(PyObject *list)
2008-01-20 05:30:57 -04:00
.. index:: builtin: tuple
Return a new tuple object containing the contents of *list*; equivalent to
``tuple(list)``.