[Python-Dev] is the concept of 'reference ownership' no long applicable in Python 3.4?

Jianfeng Mao jmao at rocketsoftware.com
Thu Apr 17 17:34:26 CEST 2014


Hi,

I noticed the following changes in the C API manuals from 3.3.5 (and earlier versions) to 3.4. I don't know if these changes are deliberate and imply that we C extension developers no longer need to care about 'reference ownership' because of some improvements in 3.4. Could anyone clarify it?

Thanks,
Jianfeng


--- 3.4  C API  reference manual ----
PyObject<https://docs.python.org/3/c-api/structures.html#c.PyObject>* PySequence_GetItem(PyObject<https://docs.python.org/3/c-api/structures.html#c.PyObject> *o, Py_ssize_t i)¶<https://docs.python.org/3/c-api/sequence.html#c.PySequence_GetItem>

Return the ith element of o, or NULL on failure. This is the equivalent of the Python expression o[i].
PyObject<https://docs.python.org/3.4/c-api/structures.html#c.PyObject>* PyList_GetItem(PyObject<https://docs.python.org/3.4/c-api/structures.html#c.PyObject> *list, Py_ssize_t index)

Return the object at position index in the list pointed to by list. The position must be positive, indexing from the end of the list is not supported. If index is out of bounds, return NULL and set an IndexError<https://docs.python.org/3.4/library/exceptions.html#IndexError> exception.

--- 3.3.5 C API reference manual ---
PyObject<https://docs.python.org/3.3/c-api/structures.html#PyObject>* PySequence_GetItem(PyObject<https://docs.python.org/3.3/c-api/structures.html#PyObject> *o, Py_ssize_t i)¶<https://docs.python.org/3.3/c-api/sequence.html#PySequence_GetItem>
Return value: New reference.

Return the ith element of o, or NULL on failure. This is the equivalent of the Python expression o[i].

PyObject<https://docs.python.org/3.3/c-api/structures.html#PyObject>* PyList_GetItem(PyObject<https://docs.python.org/3.3/c-api/structures.html#PyObject> *list, Py_ssize_t index)
Return value: Borrowed reference.

Return the object at position index in the list pointed to by list. The position must be positive, indexing from the end of the list is not supported. If index is out of bounds, return NULL and set an IndexError<https://docs.python.org/3.3/library/exceptions.html#IndexError> exception.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140417/bb53bfe1/attachment.html>


More information about the Python-Dev mailing list