Author wim.glenn
Recipients docs@python, wim.glenn
Date 2019-10-22.15:51:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571759460.27.0.105772262724.issue38557@roundup.psfhosted.org>
In-reply-to
Content
https://docs.python.org/3/c-api/tuple.html#c.PyTuple_GetSlice

In the c-api it says (emphasis mine):

    PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)ΒΆ
    Return value: New reference.

    Take a slice of the tuple pointed to by p from low to high and return it **as a new tuple**.

But when slicing the entire tuple, CPython will return already existing instance, not a new tuple.

https://github.com/python/cpython/blob/3.8/Objects/tupleobject.c#L448-L451

I propose the language in the docs be loosened so as not to tie the hands of implementation
History
Date User Action Args
2019-10-22 15:51:00wim.glennsetrecipients: + wim.glenn, docs@python
2019-10-22 15:51:00wim.glennsetmessageid: <1571759460.27.0.105772262724.issue38557@roundup.psfhosted.org>
2019-10-22 15:51:00wim.glennlinkissue38557 messages
2019-10-22 15:51:00wim.glenncreate