Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
57b7dbc4
Commit
57b7dbc4
authored
Sep 12, 2019
by
Matti Picus
Committed by
Benjamin Peterson
Sep 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emphasize the need to always call PySequence_Fast. (GH-11140)
parent
088b63ea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
Doc/c-api/sequence.rst
Doc/c-api/sequence.rst
+14
-7
No files found.
Doc/c-api/sequence.rst
View file @
57b7dbc4
...
...
@@ -130,10 +130,17 @@ Sequence Protocol
.. c:function:: PyObject* PySequence_Fast(PyObject *o, const char *m)
Return the sequence or iterable *o* as a list, unless it is already a tuple or list, in
which case *o* is returned. Use :c:func:`PySequence_Fast_GET_ITEM` to access
the members of the result. Returns *NULL* on failure. If the object is not
a sequence or iterable, raises :exc:`TypeError` with *m* as the message text.
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
*NULL* on failure.
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.
.. c:function:: Py_ssize_t PySequence_Fast_GET_SIZE(PyObject *o)
...
...
@@ -141,8 +148,8 @@ Sequence Protocol
Returns the length of *o*, assuming that *o* was returned by
:c:func:`PySequence_Fast` and that *o* is not *NULL*. The size can also be
gotten by calling :c:func:`PySequence_Size` on *o*, but
:c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a
list
or tuple.
:c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a
list
or tuple.
.. c:function:: PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i)
...
...
@@ -163,7 +170,7 @@ Sequence Protocol
.. c:function:: PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i)
Return the *i*\ th element of *o* or *NULL* on failure.
Macro
form of
Return the *i*\ th element of *o* or *NULL* on failure.
Faster
form of
:c:func:`PySequence_GetItem` but without checking that
:c:func:`PySequence_Check` on *o* is true and without adjustment for negative
indices.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment