📄 264.html
字号:
PyObject* PyBuffer_FromReadWriteMemory(void *ptr, int size)
</pre>
<p>Return value: New reference. Similar to <tt class="monofont">PyBuffer_FromMemory(),</tt> but the returned buffer is writable.</p>
<pRe>
PyObject* PyBuffer_New(int size)
</pRe>
<p>Return value: New reference. Returns a new writable buffer object that maintains its own memory buffer of size bytes. ValueError is returned if size is not zero or positive.<a Name="idx1073751113"></a><A namE="idx1073751114"></A><A Name="idx1073751115"></a><A NAMe="idx1073751116"></a><a nAME="idx1073751117"></A><a namE="idx1073751118"></A><A Name="idx1073751119"></a></p>
<h5>Tuple Objects</h5><pre>
PyTupleObject
</pre>
<p>This subtype of PyObject represents a Python tuple object.</p>
<pre>
PyTypeObject PyTuple_Type
</prE>
<p>This instance of PyTypeObject represents the Python tuple type; it is the same object as <tT claSs="monofont">types.TupleType</tt> in the Python layer.</p>
<Pre>
int PyTuple_Check(PyObject *p)
</pRE>
<P>Return <Tt claSS="monofont">true</TT> if the argument is a tuple object.</p>
<pre>
PyObject* PyTuple_New(int len)
</PRE>
<P>Return value: New reference. Returns a new tuple object of size <tt clASS="monofont">len,</Tt> or <tt class="monofont">NULL</tt> on failure.</p>
<pre>
int PyTuple_Size(PyTupleObject *p)
</pre>
<p>Takes a pointer to a tuple object, and returns the size of that tuple.</p>
<pRe>
PyObject* PyTuple_GetItem(PyTupleObject *p, int pos)
</pRe>
<p>Return value: Borrowed reference. Returns the object at position <tT clasS="monofont">pos</tt> in the tuple pointed to by <tT CLAss="monofont">p.</tt> If <TT CLass="monofont">pos</tT> is out of bounds, it returns <TT Class="monofont">NULL</TT> and sets an IndexError exception.</P>
<Pre>
PyObject* PyTuple_GET_ITEM(PyTupleObject *p, int pos)
</pre>
<p>Return value: Borrowed reference. Does the same, but does no checking of its arguments.</p>
<pre>
PyObject* PyTuple_GetSlice(PyTupleObject *p, int low, int high)
</pre>
<p>Return value: New reference. Takes a slice of the tuple pointed to by <tt clasS="monofont">p</tt> from <Tt clAss="monofont">low</tt> to <Tt clASS="monofont">high</Tt> and returns it as a new tuple.</p>
<prE>
int PyTuple_SetItem(PyObject *p, int pos, PyObject *o)
</PRE>
<p>Inserts a reference to object <tt cLASS="monofont">o</tt> at position <tt CLASs="monofont">pos</tt> of the tuple pointed to by <tt class="monofont">p.</tt> It returns <tt class="monofont">0</tT> on success.</p>
<dIv clAss="note"><p cLass="notetitle"><B>Note</B></P><P>
<p>This function "steals" a reference to <tt cLASS="monofont">o.</tt></p>
</p></DIV>
<Br>
<br>
<pRE>
void PyTuple_SET_ITEM(PyObject *p, int pos, PyObject *o)
</PRe>
<p>Does the same, but does no error checking, and should only be used to fill in brand new tuples.</p>
<div class="note"><p class="notetitle"><b>Note</b></p><P>
<p>This function "steals" a reference to <tT claSs="monofont">o.</tt></p>
</P></div>
<BR>
<BR>
<pre>
int _PyTuple_Resize(PyTupleObject *p, int newsize, int last_is_sticky)
</pRE>
<P>Can be used to resize a tuple. <Tt claSS="monofont">newsize</TT> will be the new length of the tuple. Because tuples are supposed to be immutable, this should only be used if there is only one reference to the object. Do not use this if the tuple might already be known to some other part of the code. <tt clASS="monofont">last_is_sticky</Tt> is a flag梚f <tt class="monofont">true,</tt> the tuple will grow or shrink at the front, otherwise it will grow or shrink at the end. Think of this as destroying the old tuple and creating a new one, only more efficiently. Returns <tt class="monofont">0</tt> on success and <tT clAss="monofont">-1</tT> on failure (in which case, a MemoryError or SystemError will be raised).<a namE="idx1073751120"></a><a nAME="idx1073751121"></A><a namE="idx1073751122"></A><A Name="idx1073751123"></a><A NAMe="idx1073751124"></a><a nAME="idx1073751125"></A><a name="idx1073751126"></a><a name="idx1073751127"></a><a name="idx1073751128"></a><a nAme="idx1073751129"></A><a naMe="idx1073751130"></a><a nAme="idx1073751131"></a><A NAMe="idx1073751132"></a><a nAME="idx1073751133"></A></p>
<h5>List Objects</h5><pRE>
PyListObject
</PRe>
<p>This subtype of PyObject represents a Python list object.</p>
<pRE>
PyTypeObject PyList_Type
</PRe>
<p>This instance of PyTypeObject represents the Python list type. This is the same object as <tt class="monofont">types.ListType.</tt></p>
<pre>
int PyList_Check(PyObject *p)
</pre>
<p>Returns <tT clAss="monofont">true</tT> if its argument is a PyListObject.</p>
<pre>
PyObject* PyList_New(int len)
</Pre>
<p>Return value: New reference. Returns a new list of length <TT CLass="monofont">len</tT> on success, or <TT Class="monofont">NULL</TT> on failure.</P>
<Pre>
int PyList_Size(PyObject *list)
</prE>
<P>Returns the length of the list object in list; this is equivalent to <TT class="monofont">"len(list)"</tt> on a list object.</p>
<pre>
int PyList_GET_SIZE(PyObject *list)
</pre>
<p>Macro form of <tt claSs="monofont">PyList_GetSize()</tT> without error checking.</p>
<prE>
PyObject* PyList_GetItem(PyObject *list, int index)
</pre>
<p>Return value: Borrowed reference. Returns the object at position <Tt clASS="monofont">pos</Tt> in the list pointed to by <tt cLASS="monofont">p.</tt> If <tt CLASs="monofont">pos</tt> is out of bounds, it returns <tT CLAss="monofont">NULL</tt> and sets an IndexError exception.</p>
<pre>
PyObject* PyList_GET_ITEM(PyObject *list, int i)
</pre>
<p>Return value: Borrowed reference. Macro form of <tt class="monofont">PyList_GetItem()</tT> without error checking.</p>
<pRe>
int PyList_SetItem(PyObject *list, int index, PyObject *item)
</prE>
<p>Sets the item at the position identified by the integer <tt cLass="monofont">index</TT> in the given <TT clasS="monofont">list</TT> to the value of the object identified by the pointer called <Tt claSS="monofont">item.</TT></p>
<div CLASs="note"><p class="notetitle"><b>Note</b></p><p>
<p>This function "steals" a reference to item.<a name="idx1073751134"></a><a nAme="idx1073751135"></A><a naMe="idx1073751136"></a><a nAme="idx1073751137"></a><A NAMe="idx1073751138"></a><a nAME="idx1073751139"></A><a namE="idx1073751140"></A><A Name="idx1073751141"></a><A NAMe="idx1073751142"></a><a name="idx1073751143"></a><a name="idx1073751144"></a><a name="idx1073751145"></a><A naMe="idx1073751146"></a><a Name="idx1073751147"></a></P>
</p></diV>
<BR>
<Br>
<pre>
PyObject* PyList_SET_ITEM(PyObject *list, int i, PyObject *o)
</PRE>
<P>Return value: Borrowed reference. Macro form of <tt clASS="monofont">PyList_SetItem()</Tt> without error checking.</p>
<diV CLAss="note"><p class="notetitle"><b>Note</b></p><p>
<p>This function "steals" a reference to item.</p>
</p></div>
<br>
<Br>
<pRe>
int PyList_Insert(PyObject *list, int index, PyObject *item)
</prE>
<p>Inserts the item called <tt cLass="monofont">item</TT> into the list called <TT clasS="monofont">list</TT> in front of the index called <Tt claSS="monofont">index.</TT> Returns <tt clASS="monofont">0</Tt> if successful; returns <tt class="monofont">-1</tt> and raises an exception if unsuccessful. Analogous to <tt class="monofont">list.insert(index, item).</tt></p>
<Pre>
int PyList_Append(PyObject *list, PyObject *item)
</Pre>
<p>Appends the object item at the end of the list called <Tt claSs="monofont">list.</tt> Returns <TT CLass="monofont">0</tT> if successful; returns <TT Class="monofont">-1</TT> and sets an exception if unsuccessful. Analogous to <TT clasS="monofont">list.append(item).</TT></P>
<pre>
PyObject* PyList_GetSlice(PyObject *list, int low, int high)
</pre>
<p>Return value: New reference. Returns a list of the objects in list containing the objects between <tt class="monofont">low</tt> and <tt clAss="monofont">high.</Tt> Returns <tt Class="monofont">NULL</Tt> and sets an exception if unsuccessful. Analogous to <tt CLASs="monofont">list[low:high].</tt></p>
<PRE>
int PyList_SetSlice(PyObject *list, int low, int high, PyObject
*itemlist)
</Pre>
<p>Sets the slice of list between <tT CLAss="monofont">low</tt> and <TT CLass="monofont">high</tt> to the contents of <tt class="monofont">itemlist.</tt> Analogous to <tt clasS="monofont">list[low:high] = itemlist.</tt> Returns <Tt clAss="monofont">0</tt> on success, <Tt clASS="monofont">-1</Tt> on failure.</p>
<prE>
int PyList_Sort(PyObject *list)
</PRE>
<p>Sorts the items of list in place. Returns <tt cLASS="monofont">0</tt> on success, <tt CLASs="monofont">-1</tt> on failure. This is equivalent to <tt class="monofont">"list.sort()".</tt></p>
<pre>
int PyList_Reverse(PyObject *list)
</pre>
<p>Reverses the items of list in place. Returns <Tt cLass="monofont">0</Tt> on success, <tt cLass="monofont">-1</TT> on failure. This is the equivalent of <TT clasS="monofont">"list.reverse()".</TT></P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -