New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation claims that PySequence_Fast returns a tuple, when it actually returns a list. #60599
Comments
The documentation in Python 2.7, 3.2, and 3.3 claim that: PyObject* PySequence_Fast(PyObject *o, const char *m)
Return value: New reference.
Returns the sequence o as a tuple, unless it is already a tuple or list, in which case o is returned... Unfortunately, the code does this in Objects/abstract.c: v = PySequence_List(it); And the header file in Include/abstract.h matches the documentation: PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
/*
Returns the sequence, o, as a tuple, unless it's already a
tuple or list.
*/ |
It looks like this was caught in the 3.3 branch, but only fixed it in the comment: changeset: 75448:d8f68195210e The included patch applies cleanly to Python 2.7 and 3.2. When applying to 3.3, include the failure in Objects/abstract.c because the same change has already been made. |
Larry, any objection to backporting this? |
PySequence_Tuple() was changed to PySequence_List() in the changeset 4714aff4bf75 in 2004. Are there any measurements which show PySequence_List() faster than PySequence_Tuple() on modern Python? I don't see any references in 4714aff4bf75 description. |
Any news on this? I was about to open a bug of my own for this, since the docs and code are still out of sync. |
As far as performance goes, presumably the length hinting API reduces the number of cases in which we're working with completely unsized iterables, right? |
I have no objections to someone backporting this. |
New changeset b2187b82a658 by Benjamin Peterson in branch '3.4': New changeset b235db467cd5 by Benjamin Peterson in branch '2.7': New changeset c833c35aa13a by Benjamin Peterson in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: