2019-05-17 06:55:34 -03:00
|
|
|
.. highlight:: c
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
.. _sequence:
|
|
|
|
|
|
|
|
Sequence Protocol
|
|
|
|
=================
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PySequence_Check(PyObject *o)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2022-04-02 16:31:05 -03:00
|
|
|
Return ``1`` if the object provides the sequence protocol, and ``0`` otherwise.
|
2023-07-23 06:23:44 -03:00
|
|
|
Note that it returns ``1`` for Python classes with a :meth:`~object.__getitem__`
|
2022-04-02 16:31:05 -03:00
|
|
|
method, unless they are :class:`dict` subclasses, since in general it
|
|
|
|
is impossible to determine what type of keys the class supports. This
|
2018-05-22 05:02:44 -03:00
|
|
|
function always succeeds.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: Py_ssize_t PySequence_Size(PyObject *o)
|
Merged revisions 71898-71900,71910,71914-71919 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r71898 | jeroen.ruigrok | 2009-04-25 16:24:30 +0200 (za, 25 apr 2009) | 2 lines
Reformat prior to editing.
........
r71899 | jeroen.ruigrok | 2009-04-25 16:27:00 +0200 (za, 25 apr 2009) | 3 lines
The type for ppos has been Py_ssize_t since 2.5, reflect this in the
documentation.
........
r71900 | jeroen.ruigrok | 2009-04-25 16:28:02 +0200 (za, 25 apr 2009) | 2 lines
Reformat paragraph.
........
r71910 | jeroen.ruigrok | 2009-04-25 19:59:03 +0200 (za, 25 apr 2009) | 4 lines
Issue #4129: Belatedly document which C API functions had their argument(s) or
return type changed from int or int * to Py_ssize_t or Py_ssize_t * as this
might cause problems on 64-bit platforms.
........
r71914 | jeroen.ruigrok | 2009-04-25 20:31:20 +0200 (za, 25 apr 2009) | 2 lines
Reformat prior to editing.
........
r71915 | jeroen.ruigrok | 2009-04-25 20:46:03 +0200 (za, 25 apr 2009) | 2 lines
Issue #4129: Document more int -> Py_ssize_t changes.
........
r71916 | jeroen.ruigrok | 2009-04-25 20:53:48 +0200 (za, 25 apr 2009) | 2 lines
Reformat prior to editing.
........
r71917 | jeroen.ruigrok | 2009-04-25 20:57:32 +0200 (za, 25 apr 2009) | 2 lines
Reference to an int type, whereas it's a Py_ssize_t as the synopsis states.
........
r71918 | jeroen.ruigrok | 2009-04-25 21:04:15 +0200 (za, 25 apr 2009) | 2 lines
Since I edited this file, reformat for future edits.
........
r71919 | jeroen.ruigrok | 2009-04-25 21:10:52 +0200 (za, 25 apr 2009) | 2 lines
Reformat prior to editing.
........
2009-04-26 18:06:15 -03:00
|
|
|
Py_ssize_t PySequence_Length(PyObject *o)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-05-06 00:54:08 -03:00
|
|
|
.. index:: pair: built-in function; len
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2018-02-20 13:24:29 -04:00
|
|
|
Returns the number of objects in sequence *o* on success, and ``-1`` on
|
|
|
|
failure. This is equivalent to the Python expression ``len(o)``.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_Concat(PyObject *o1, PyObject *o2)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Return the concatenation of *o1* and *o2* on success, and ``NULL`` on failure.
|
2008-01-20 05:30:57 -04:00
|
|
|
This is the equivalent of the Python expression ``o1 + o2``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Return the result of repeating sequence object *o* *count* times, or ``NULL`` on
|
2008-01-20 05:30:57 -04:00
|
|
|
failure. This is the equivalent of the Python expression ``o * count``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Return the concatenation of *o1* and *o2* on success, and ``NULL`` on failure.
|
2008-01-20 05:30:57 -04:00
|
|
|
The operation is done *in-place* when *o1* supports it. This is the equivalent
|
|
|
|
of the Python expression ``o1 += o2``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Return the result of repeating sequence object *o* *count* times, or ``NULL`` on
|
2008-01-20 05:30:57 -04:00
|
|
|
failure. The operation is done *in-place* when *o* supports it. This is the
|
|
|
|
equivalent of the Python expression ``o *= count``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Return the *i*\ th element of *o*, or ``NULL`` on failure. This is the equivalent of
|
2008-01-20 05:30:57 -04:00
|
|
|
the Python expression ``o[i]``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Return the slice of sequence object *o* between *i1* and *i2*, or ``NULL`` on
|
2008-01-20 05:30:57 -04:00
|
|
|
failure. This is the equivalent of the Python expression ``o[i1:i2]``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2015-12-07 20:03:20 -04:00
|
|
|
Assign object *v* to the *i*\ th element of *o*. Raise an exception
|
|
|
|
and return ``-1`` on failure; return ``0`` on success. This
|
2008-01-20 05:30:57 -04:00
|
|
|
is the equivalent of the Python statement ``o[i] = v``. This function *does
|
|
|
|
not* steal a reference to *v*.
|
|
|
|
|
2022-04-02 16:31:05 -03:00
|
|
|
If *v* is ``NULL``, the element is deleted, but this feature is
|
2015-12-07 20:03:20 -04:00
|
|
|
deprecated in favour of using :c:func:`PySequence_DelItem`.
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PySequence_DelItem(PyObject *o, Py_ssize_t i)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
Merged revisions 72506,72525-72526,72551,72558,72616,72654-72655,72689,72745,72750,72802,72812,72822,72824,72826-72827,72833,72876,72890,72923,72946,73026,73042,73045,73047,73065,73068-73069 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72506 | vinay.sajip | 2009-05-09 07:07:17 -0500 (Sat, 09 May 2009) | 1 line
Issue #5971: StreamHandler.handleError now swallows IOErrors which occur when trying to print a traceback.
........
r72525 | benjamin.peterson | 2009-05-09 20:38:02 -0500 (Sat, 09 May 2009) | 1 line
close file explicitly
........
r72526 | benjamin.peterson | 2009-05-09 21:29:00 -0500 (Sat, 09 May 2009) | 1 line
make sure files are closed using the with statement
........
r72551 | benjamin.peterson | 2009-05-10 09:16:47 -0500 (Sun, 10 May 2009) | 1 line
use isinstance
........
r72558 | benjamin.peterson | 2009-05-10 18:52:09 -0500 (Sun, 10 May 2009) | 1 line
sys.setdefaultencoding() strikes me as a bad example
........
r72616 | benjamin.peterson | 2009-05-13 19:33:10 -0500 (Wed, 13 May 2009) | 1 line
importlib.import_module is better these days
........
r72654 | benjamin.peterson | 2009-05-14 17:37:49 -0500 (Thu, 14 May 2009) | 1 line
prevent refleaks from threads
........
r72655 | benjamin.peterson | 2009-05-14 17:40:34 -0500 (Thu, 14 May 2009) | 1 line
a useful decorator for cleaning up threads
........
r72689 | benjamin.peterson | 2009-05-16 13:44:34 -0500 (Sat, 16 May 2009) | 1 line
use skipTest()
........
r72745 | benjamin.peterson | 2009-05-17 09:16:29 -0500 (Sun, 17 May 2009) | 1 line
ignore .rst files in sphinx its self
........
r72750 | benjamin.peterson | 2009-05-17 11:59:27 -0500 (Sun, 17 May 2009) | 1 line
chop off slash
........
r72802 | georg.brandl | 2009-05-20 13:35:27 -0500 (Wed, 20 May 2009) | 1 line
#6051: refer to email examples for better way to construct email messages.
........
r72812 | michael.foord | 2009-05-21 17:57:02 -0500 (Thu, 21 May 2009) | 1 line
Rename TestCase._result to _resultForDoCleanups to avoid potential clashes in TestCase subclasses. Issue 6072.
........
r72822 | georg.brandl | 2009-05-22 04:33:25 -0500 (Fri, 22 May 2009) | 1 line
#6084: fix example.
........
r72824 | georg.brandl | 2009-05-22 04:43:17 -0500 (Fri, 22 May 2009) | 1 line
Fix references to file-related functions and methods (os.* vs file.*).
........
r72826 | georg.brandl | 2009-05-22 04:49:42 -0500 (Fri, 22 May 2009) | 1 line
Fix confusing wording.
........
r72827 | georg.brandl | 2009-05-22 04:50:30 -0500 (Fri, 22 May 2009) | 1 line
s/use/call/
........
r72833 | georg.brandl | 2009-05-22 12:00:17 -0500 (Fri, 22 May 2009) | 1 line
#6078: _warnings is a builtin module and has no standard init_warnings function.
........
r72876 | benjamin.peterson | 2009-05-23 15:59:09 -0500 (Sat, 23 May 2009) | 1 line
remove mention of old ctypes version
........
r72890 | gregory.p.smith | 2009-05-24 13:00:13 -0500 (Sun, 24 May 2009) | 2 lines
add a versionadded tag for set_tunnel
........
r72923 | michael.foord | 2009-05-25 15:36:56 -0500 (Mon, 25 May 2009) | 1 line
Make assertSequenceEqual error messages less cryptic, particularly for nested sequences.
........
r72946 | ronald.oussoren | 2009-05-26 13:44:48 -0500 (Tue, 26 May 2009) | 2 lines
Fixes issue 6110
........
r73026 | r.david.murray | 2009-05-29 14:30:27 -0500 (Fri, 29 May 2009) | 3 lines
Issue 6141: document that the first item of args is still the
command name even when executable is specified.
........
r73042 | benjamin.peterson | 2009-05-29 22:10:52 -0500 (Fri, 29 May 2009) | 1 line
no fdatasync on macos
........
r73045 | georg.brandl | 2009-05-30 02:26:04 -0500 (Sat, 30 May 2009) | 1 line
#6146: fix markup bug.
........
r73047 | georg.brandl | 2009-05-30 05:33:23 -0500 (Sat, 30 May 2009) | 1 line
Fix some more small markup problems.
........
r73065 | antoine.pitrou | 2009-05-30 16:39:25 -0500 (Sat, 30 May 2009) | 3 lines
The test for #5330 wasn't correct.
........
r73068 | antoine.pitrou | 2009-05-30 16:45:40 -0500 (Sat, 30 May 2009) | 3 lines
Update ACKS
........
r73069 | benjamin.peterson | 2009-05-30 19:42:42 -0500 (Sat, 30 May 2009) | 1 line
fix signature
........
2009-06-01 19:42:33 -03:00
|
|
|
Delete the *i*\ th element of object *o*. Returns ``-1`` on failure. This is the
|
2008-01-20 05:30:57 -04:00
|
|
|
equivalent of the Python statement ``del o[i]``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Assign the sequence object *v* to the slice in sequence object *o* from *i1* to
|
|
|
|
*i2*. This is the equivalent of the Python statement ``o[i1:i2] = v``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Delete the slice in sequence object *o* from *i1* to *i2*. Returns ``-1`` on
|
|
|
|
failure. This is the equivalent of the Python statement ``del o[i1:i2]``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: Py_ssize_t PySequence_Count(PyObject *o, PyObject *value)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Return the number of occurrences of *value* in *o*, that is, return the number
|
|
|
|
of keys for which ``o[key] == value``. On failure, return ``-1``. This is
|
|
|
|
equivalent to the Python expression ``o.count(value)``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PySequence_Contains(PyObject *o, PyObject *value)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Determine if *o* contains *value*. If an item in *o* is equal to *value*,
|
|
|
|
return ``1``, otherwise return ``0``. On error, return ``-1``. This is
|
|
|
|
equivalent to the Python expression ``value in o``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: Py_ssize_t PySequence_Index(PyObject *o, PyObject *value)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Return the first index *i* for which ``o[i] == value``. On error, return
|
|
|
|
``-1``. This is equivalent to the Python expression ``o.index(value)``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_List(PyObject *o)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2015-03-12 21:55:45 -03:00
|
|
|
Return a list object with the same contents as the sequence or iterable *o*,
|
2019-10-30 07:03:20 -03:00
|
|
|
or ``NULL`` on failure. The returned list is guaranteed to be new. This is
|
2015-03-12 21:55:45 -03:00
|
|
|
equivalent to the Python expression ``list(o)``.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_Tuple(PyObject *o)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-05-06 00:54:08 -03:00
|
|
|
.. index:: pair: built-in function; tuple
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2018-05-22 05:02:44 -03:00
|
|
|
Return a tuple object with the same contents as the sequence or iterable *o*,
|
2019-10-30 07:03:20 -03:00
|
|
|
or ``NULL`` on failure. If *o* is a tuple, a new reference will be returned,
|
2008-01-20 05:30:57 -04:00
|
|
|
otherwise a tuple will be constructed with the appropriate contents. This is
|
|
|
|
equivalent to the Python expression ``tuple(o)``.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_Fast(PyObject *o, const char *m)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-09-12 13:19:06 -03:00
|
|
|
Return the sequence or iterable *o* as an object usable by the other
|
|
|
|
``PySequence_Fast*`` family of functions. If the object is not a sequence or
|
|
|
|
iterable, raises :exc:`TypeError` with *m* as the message text. Returns
|
2019-10-30 07:03:20 -03:00
|
|
|
``NULL`` on failure.
|
2019-09-12 13:19:06 -03:00
|
|
|
|
|
|
|
The ``PySequence_Fast*`` functions are thus named because they assume
|
|
|
|
*o* is a :c:type:`PyTupleObject` or a :c:type:`PyListObject` and access
|
|
|
|
the data fields of *o* directly.
|
|
|
|
|
|
|
|
As a CPython implementation detail, if *o* is already a sequence or list, it
|
|
|
|
will be returned.
|
2018-05-22 05:02:44 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. c:function:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o)
|
|
|
|
|
|
|
|
Returns the length of *o*, assuming that *o* was returned by
|
2019-10-30 07:03:20 -03:00
|
|
|
:c:func:`PySequence_Fast` and that *o* is not ``NULL``. The size can also be
|
2022-04-02 16:31:05 -03:00
|
|
|
retrieved by calling :c:func:`PySequence_Size` on *o*, but
|
2019-09-12 13:19:06 -03:00
|
|
|
:c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a
|
|
|
|
list or tuple.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
Merged revisions 72506,72525-72526,72551,72558,72616,72654-72655,72689,72745,72750,72802,72812,72822,72824,72826-72827,72833,72876,72890,72923,72946,73026,73042,73045,73047,73065,73068-73069 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72506 | vinay.sajip | 2009-05-09 07:07:17 -0500 (Sat, 09 May 2009) | 1 line
Issue #5971: StreamHandler.handleError now swallows IOErrors which occur when trying to print a traceback.
........
r72525 | benjamin.peterson | 2009-05-09 20:38:02 -0500 (Sat, 09 May 2009) | 1 line
close file explicitly
........
r72526 | benjamin.peterson | 2009-05-09 21:29:00 -0500 (Sat, 09 May 2009) | 1 line
make sure files are closed using the with statement
........
r72551 | benjamin.peterson | 2009-05-10 09:16:47 -0500 (Sun, 10 May 2009) | 1 line
use isinstance
........
r72558 | benjamin.peterson | 2009-05-10 18:52:09 -0500 (Sun, 10 May 2009) | 1 line
sys.setdefaultencoding() strikes me as a bad example
........
r72616 | benjamin.peterson | 2009-05-13 19:33:10 -0500 (Wed, 13 May 2009) | 1 line
importlib.import_module is better these days
........
r72654 | benjamin.peterson | 2009-05-14 17:37:49 -0500 (Thu, 14 May 2009) | 1 line
prevent refleaks from threads
........
r72655 | benjamin.peterson | 2009-05-14 17:40:34 -0500 (Thu, 14 May 2009) | 1 line
a useful decorator for cleaning up threads
........
r72689 | benjamin.peterson | 2009-05-16 13:44:34 -0500 (Sat, 16 May 2009) | 1 line
use skipTest()
........
r72745 | benjamin.peterson | 2009-05-17 09:16:29 -0500 (Sun, 17 May 2009) | 1 line
ignore .rst files in sphinx its self
........
r72750 | benjamin.peterson | 2009-05-17 11:59:27 -0500 (Sun, 17 May 2009) | 1 line
chop off slash
........
r72802 | georg.brandl | 2009-05-20 13:35:27 -0500 (Wed, 20 May 2009) | 1 line
#6051: refer to email examples for better way to construct email messages.
........
r72812 | michael.foord | 2009-05-21 17:57:02 -0500 (Thu, 21 May 2009) | 1 line
Rename TestCase._result to _resultForDoCleanups to avoid potential clashes in TestCase subclasses. Issue 6072.
........
r72822 | georg.brandl | 2009-05-22 04:33:25 -0500 (Fri, 22 May 2009) | 1 line
#6084: fix example.
........
r72824 | georg.brandl | 2009-05-22 04:43:17 -0500 (Fri, 22 May 2009) | 1 line
Fix references to file-related functions and methods (os.* vs file.*).
........
r72826 | georg.brandl | 2009-05-22 04:49:42 -0500 (Fri, 22 May 2009) | 1 line
Fix confusing wording.
........
r72827 | georg.brandl | 2009-05-22 04:50:30 -0500 (Fri, 22 May 2009) | 1 line
s/use/call/
........
r72833 | georg.brandl | 2009-05-22 12:00:17 -0500 (Fri, 22 May 2009) | 1 line
#6078: _warnings is a builtin module and has no standard init_warnings function.
........
r72876 | benjamin.peterson | 2009-05-23 15:59:09 -0500 (Sat, 23 May 2009) | 1 line
remove mention of old ctypes version
........
r72890 | gregory.p.smith | 2009-05-24 13:00:13 -0500 (Sun, 24 May 2009) | 2 lines
add a versionadded tag for set_tunnel
........
r72923 | michael.foord | 2009-05-25 15:36:56 -0500 (Mon, 25 May 2009) | 1 line
Make assertSequenceEqual error messages less cryptic, particularly for nested sequences.
........
r72946 | ronald.oussoren | 2009-05-26 13:44:48 -0500 (Tue, 26 May 2009) | 2 lines
Fixes issue 6110
........
r73026 | r.david.murray | 2009-05-29 14:30:27 -0500 (Fri, 29 May 2009) | 3 lines
Issue 6141: document that the first item of args is still the
command name even when executable is specified.
........
r73042 | benjamin.peterson | 2009-05-29 22:10:52 -0500 (Fri, 29 May 2009) | 1 line
no fdatasync on macos
........
r73045 | georg.brandl | 2009-05-30 02:26:04 -0500 (Sat, 30 May 2009) | 1 line
#6146: fix markup bug.
........
r73047 | georg.brandl | 2009-05-30 05:33:23 -0500 (Sat, 30 May 2009) | 1 line
Fix some more small markup problems.
........
r73065 | antoine.pitrou | 2009-05-30 16:39:25 -0500 (Sat, 30 May 2009) | 3 lines
The test for #5330 wasn't correct.
........
r73068 | antoine.pitrou | 2009-05-30 16:45:40 -0500 (Sat, 30 May 2009) | 3 lines
Update ACKS
........
r73069 | benjamin.peterson | 2009-05-30 19:42:42 -0500 (Sat, 30 May 2009) | 1 line
fix signature
........
2009-06-01 19:42:33 -03:00
|
|
|
Return the *i*\ th element of *o*, assuming that *o* was returned by
|
2019-10-30 07:03:20 -03:00
|
|
|
:c:func:`PySequence_Fast`, *o* is not ``NULL``, and that *i* is within bounds.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject** PySequence_Fast_ITEMS(PyObject *o)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Return the underlying array of PyObject pointers. Assumes that *o* was returned
|
2019-10-30 07:03:20 -03:00
|
|
|
by :c:func:`PySequence_Fast` and *o* is not ``NULL``.
|
2009-01-03 17:18:54 -04:00
|
|
|
|
Merged revisions 64722,64729,64753,64845-64846,64849,64871,64880-64882,64885,64888,64897,64900-64901,64915,64926-64929,64938-64941,64944,64961,64966,64973 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64722 | georg.brandl | 2008-07-05 12:13:36 +0200 (Sat, 05 Jul 2008) | 4 lines
#2663: support an *ignore* argument to shutil.copytree(). Patch by Tarek Ziade.
This is a new feature, but Barry authorized adding it in the beta period.
........
r64729 | mark.dickinson | 2008-07-05 13:33:52 +0200 (Sat, 05 Jul 2008) | 5 lines
Issue 3188: accept float('infinity') as well as float('inf'). This
makes the float constructor behave in the same way as specified
by various other language standards, including C99, IEEE 754r,
and the IBM Decimal standard.
........
r64753 | gregory.p.smith | 2008-07-06 05:35:58 +0200 (Sun, 06 Jul 2008) | 4 lines
- Issue #2862: Make int and float freelist management consistent with other
freelists. Changes their CompactFreeList apis into ClearFreeList apis and
calls them via gc.collect().
........
r64845 | raymond.hettinger | 2008-07-10 16:03:19 +0200 (Thu, 10 Jul 2008) | 1 line
Issue 3301: Bisect functions behaved badly when lo was negative.
........
r64846 | raymond.hettinger | 2008-07-10 16:34:57 +0200 (Thu, 10 Jul 2008) | 1 line
Issue 3285: Fractions from_float() and from_decimal() accept Integral arguments.
........
r64849 | andrew.kuchling | 2008-07-10 16:43:31 +0200 (Thu, 10 Jul 2008) | 1 line
Wording changes
........
r64871 | raymond.hettinger | 2008-07-11 14:00:21 +0200 (Fri, 11 Jul 2008) | 1 line
Add cautionary note on the use of PySequence_Fast_ITEMS.
........
r64880 | amaury.forgeotdarc | 2008-07-11 23:28:25 +0200 (Fri, 11 Jul 2008) | 5 lines
#3317 in zipfile module, restore the previous names of global variables:
some applications relied on them.
Also remove duplicated lines.
........
r64881 | amaury.forgeotdarc | 2008-07-11 23:45:06 +0200 (Fri, 11 Jul 2008) | 3 lines
#3342: In tracebacks, printed source lines were not indented since r62555.
#3343: Py_DisplaySourceLine should be a private function. Rename it to _Py_DisplaySourceLine.
........
r64882 | josiah.carlson | 2008-07-12 00:17:14 +0200 (Sat, 12 Jul 2008) | 2 lines
Fix for the AttributeError in test_asynchat.
........
r64885 | josiah.carlson | 2008-07-12 01:26:59 +0200 (Sat, 12 Jul 2008) | 2 lines
Fixed test for asyncore.
........
r64888 | matthias.klose | 2008-07-12 09:51:48 +0200 (Sat, 12 Jul 2008) | 2 lines
- Fix bashisms in Tools/faqwiz/move-faqwiz.sh
........
r64897 | benjamin.peterson | 2008-07-12 22:16:19 +0200 (Sat, 12 Jul 2008) | 1 line
fix various doc typos #3320
........
r64900 | alexandre.vassalotti | 2008-07-13 00:06:53 +0200 (Sun, 13 Jul 2008) | 2 lines
Fixed typo.
........
r64901 | benjamin.peterson | 2008-07-13 01:41:19 +0200 (Sun, 13 Jul 2008) | 1 line
#1778443 robotparser fixes from Aristotelis Mikropoulos
........
r64915 | nick.coghlan | 2008-07-13 16:52:36 +0200 (Sun, 13 Jul 2008) | 1 line
Fix issue 3221 by emitting a RuntimeWarning instead of raising SystemError when the parent module can't be found during an absolute import (likely due to non-PEP 361 aware code which sets a module level __package__ attribute)
........
r64926 | martin.v.loewis | 2008-07-13 22:31:49 +0200 (Sun, 13 Jul 2008) | 2 lines
Add turtle into the module index.
........
r64927 | alexandre.vassalotti | 2008-07-13 22:42:44 +0200 (Sun, 13 Jul 2008) | 3 lines
Issue #3274: Use a less common identifier for the temporary variable
in Py_CLEAR().
........
r64928 | andrew.kuchling | 2008-07-13 23:43:25 +0200 (Sun, 13 Jul 2008) | 1 line
Re-word
........
r64929 | andrew.kuchling | 2008-07-13 23:43:52 +0200 (Sun, 13 Jul 2008) | 1 line
Add various items; move ctypes items into a subsection of their own
........
r64938 | andrew.kuchling | 2008-07-14 02:35:32 +0200 (Mon, 14 Jul 2008) | 1 line
Typo fixes
........
r64939 | andrew.kuchling | 2008-07-14 02:40:55 +0200 (Mon, 14 Jul 2008) | 1 line
Typo fix
........
r64940 | andrew.kuchling | 2008-07-14 03:18:16 +0200 (Mon, 14 Jul 2008) | 1 line
Typo fix
........
r64941 | andrew.kuchling | 2008-07-14 03:18:31 +0200 (Mon, 14 Jul 2008) | 1 line
Expand the multiprocessing section
........
r64944 | gregory.p.smith | 2008-07-14 08:06:48 +0200 (Mon, 14 Jul 2008) | 7 lines
Fix posix.fork1() / os.fork1() to only call PyOS_AfterFork() in the child
process rather than both parent and child.
Does anyone actually use fork1()? It appears to be a Solaris thing
but if Python is built with pthreads on Solaris, fork1() and fork()
should be the same.
........
r64961 | jesse.noller | 2008-07-15 15:47:33 +0200 (Tue, 15 Jul 2008) | 1 line
multiprocessing/connection.py patch to remove fqdn oddness for issue 3270
........
r64966 | nick.coghlan | 2008-07-15 17:40:22 +0200 (Tue, 15 Jul 2008) | 1 line
Add missing NEWS entry for r64962
........
r64973 | jesse.noller | 2008-07-15 20:29:18 +0200 (Tue, 15 Jul 2008) | 1 line
Revert 3270 patch: self._address is in pretty widespread use, need to revisit
........
2008-07-16 09:55:28 -03:00
|
|
|
Note, if a list gets resized, the reallocation may relocate the items array.
|
2009-01-03 17:18:54 -04:00
|
|
|
So, only use the underlying array pointer in contexts where the sequence
|
Merged revisions 64722,64729,64753,64845-64846,64849,64871,64880-64882,64885,64888,64897,64900-64901,64915,64926-64929,64938-64941,64944,64961,64966,64973 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64722 | georg.brandl | 2008-07-05 12:13:36 +0200 (Sat, 05 Jul 2008) | 4 lines
#2663: support an *ignore* argument to shutil.copytree(). Patch by Tarek Ziade.
This is a new feature, but Barry authorized adding it in the beta period.
........
r64729 | mark.dickinson | 2008-07-05 13:33:52 +0200 (Sat, 05 Jul 2008) | 5 lines
Issue 3188: accept float('infinity') as well as float('inf'). This
makes the float constructor behave in the same way as specified
by various other language standards, including C99, IEEE 754r,
and the IBM Decimal standard.
........
r64753 | gregory.p.smith | 2008-07-06 05:35:58 +0200 (Sun, 06 Jul 2008) | 4 lines
- Issue #2862: Make int and float freelist management consistent with other
freelists. Changes their CompactFreeList apis into ClearFreeList apis and
calls them via gc.collect().
........
r64845 | raymond.hettinger | 2008-07-10 16:03:19 +0200 (Thu, 10 Jul 2008) | 1 line
Issue 3301: Bisect functions behaved badly when lo was negative.
........
r64846 | raymond.hettinger | 2008-07-10 16:34:57 +0200 (Thu, 10 Jul 2008) | 1 line
Issue 3285: Fractions from_float() and from_decimal() accept Integral arguments.
........
r64849 | andrew.kuchling | 2008-07-10 16:43:31 +0200 (Thu, 10 Jul 2008) | 1 line
Wording changes
........
r64871 | raymond.hettinger | 2008-07-11 14:00:21 +0200 (Fri, 11 Jul 2008) | 1 line
Add cautionary note on the use of PySequence_Fast_ITEMS.
........
r64880 | amaury.forgeotdarc | 2008-07-11 23:28:25 +0200 (Fri, 11 Jul 2008) | 5 lines
#3317 in zipfile module, restore the previous names of global variables:
some applications relied on them.
Also remove duplicated lines.
........
r64881 | amaury.forgeotdarc | 2008-07-11 23:45:06 +0200 (Fri, 11 Jul 2008) | 3 lines
#3342: In tracebacks, printed source lines were not indented since r62555.
#3343: Py_DisplaySourceLine should be a private function. Rename it to _Py_DisplaySourceLine.
........
r64882 | josiah.carlson | 2008-07-12 00:17:14 +0200 (Sat, 12 Jul 2008) | 2 lines
Fix for the AttributeError in test_asynchat.
........
r64885 | josiah.carlson | 2008-07-12 01:26:59 +0200 (Sat, 12 Jul 2008) | 2 lines
Fixed test for asyncore.
........
r64888 | matthias.klose | 2008-07-12 09:51:48 +0200 (Sat, 12 Jul 2008) | 2 lines
- Fix bashisms in Tools/faqwiz/move-faqwiz.sh
........
r64897 | benjamin.peterson | 2008-07-12 22:16:19 +0200 (Sat, 12 Jul 2008) | 1 line
fix various doc typos #3320
........
r64900 | alexandre.vassalotti | 2008-07-13 00:06:53 +0200 (Sun, 13 Jul 2008) | 2 lines
Fixed typo.
........
r64901 | benjamin.peterson | 2008-07-13 01:41:19 +0200 (Sun, 13 Jul 2008) | 1 line
#1778443 robotparser fixes from Aristotelis Mikropoulos
........
r64915 | nick.coghlan | 2008-07-13 16:52:36 +0200 (Sun, 13 Jul 2008) | 1 line
Fix issue 3221 by emitting a RuntimeWarning instead of raising SystemError when the parent module can't be found during an absolute import (likely due to non-PEP 361 aware code which sets a module level __package__ attribute)
........
r64926 | martin.v.loewis | 2008-07-13 22:31:49 +0200 (Sun, 13 Jul 2008) | 2 lines
Add turtle into the module index.
........
r64927 | alexandre.vassalotti | 2008-07-13 22:42:44 +0200 (Sun, 13 Jul 2008) | 3 lines
Issue #3274: Use a less common identifier for the temporary variable
in Py_CLEAR().
........
r64928 | andrew.kuchling | 2008-07-13 23:43:25 +0200 (Sun, 13 Jul 2008) | 1 line
Re-word
........
r64929 | andrew.kuchling | 2008-07-13 23:43:52 +0200 (Sun, 13 Jul 2008) | 1 line
Add various items; move ctypes items into a subsection of their own
........
r64938 | andrew.kuchling | 2008-07-14 02:35:32 +0200 (Mon, 14 Jul 2008) | 1 line
Typo fixes
........
r64939 | andrew.kuchling | 2008-07-14 02:40:55 +0200 (Mon, 14 Jul 2008) | 1 line
Typo fix
........
r64940 | andrew.kuchling | 2008-07-14 03:18:16 +0200 (Mon, 14 Jul 2008) | 1 line
Typo fix
........
r64941 | andrew.kuchling | 2008-07-14 03:18:31 +0200 (Mon, 14 Jul 2008) | 1 line
Expand the multiprocessing section
........
r64944 | gregory.p.smith | 2008-07-14 08:06:48 +0200 (Mon, 14 Jul 2008) | 7 lines
Fix posix.fork1() / os.fork1() to only call PyOS_AfterFork() in the child
process rather than both parent and child.
Does anyone actually use fork1()? It appears to be a Solaris thing
but if Python is built with pthreads on Solaris, fork1() and fork()
should be the same.
........
r64961 | jesse.noller | 2008-07-15 15:47:33 +0200 (Tue, 15 Jul 2008) | 1 line
multiprocessing/connection.py patch to remove fqdn oddness for issue 3270
........
r64966 | nick.coghlan | 2008-07-15 17:40:22 +0200 (Tue, 15 Jul 2008) | 1 line
Add missing NEWS entry for r64962
........
r64973 | jesse.noller | 2008-07-15 20:29:18 +0200 (Tue, 15 Jul 2008) | 1 line
Revert 3270 patch: self._address is in pretty widespread use, need to revisit
........
2008-07-16 09:55:28 -03:00
|
|
|
cannot change.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Return the *i*\ th element of *o* or ``NULL`` on failure. Faster form of
|
2010-10-06 07:11:56 -03:00
|
|
|
:c:func:`PySequence_GetItem` but without checking that
|
2011-08-12 19:39:46 -03:00
|
|
|
:c:func:`PySequence_Check` on *o* is true and without adjustment for negative
|
2008-01-20 05:30:57 -04:00
|
|
|
indices.
|