mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
* Fix ref counting in extend() and extendleft().
* Let deques support reversed().
This commit is contained in:
parent
b5ba8d749d
commit
c058fd14a9
4 changed files with 101 additions and 7 deletions
|
@ -174,8 +174,7 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
if (!PyArg_UnpackTuple(args, "reversed", 1, 1, &seq))
|
||||
return NULL;
|
||||
|
||||
/* Special case optimization for xrange and lists */
|
||||
if (PyRange_Check(seq) || PyList_Check(seq))
|
||||
if (PyObject_HasAttrString(seq, "__reversed__"))
|
||||
return PyObject_CallMethod(seq, "__reversed__", NULL);
|
||||
|
||||
if (!PySequence_Check(seq)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue