Eliminate the double reverse option. It's only use case
was academic and it was potentially confusing to use.
This commit is contained in:
parent
a6366fe085
commit
d2c36261a2
|
@ -141,11 +141,8 @@ class TestReversed(unittest.TestCase):
|
|||
x = xrange(1)
|
||||
self.assertEqual(type(reversed(x)), type(iter(x)))
|
||||
|
||||
def test_double_reverse(self):
|
||||
s = 'hello'
|
||||
self.assertEqual(list(reversed(reversed(s))), list(s))
|
||||
|
||||
def test_len(self):
|
||||
# This is an implementation detail, not an interface requirement
|
||||
s = 'hello'
|
||||
self.assertEqual(len(reversed(s)), len(s))
|
||||
|
||||
|
|
|
@ -236,23 +236,11 @@ reversed_len(reversedobject *ro)
|
|||
return PyObject_Size(ro->seq);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
reversed_reverse(reversedobject *ro, PyObject *unused)
|
||||
{
|
||||
return PyObject_GetIter(ro->seq);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(reversed_doc,
|
||||
"reverse(sequence) -> reverse iterator over values of the sequence\n"
|
||||
"\n"
|
||||
"Return a reverse iterator");
|
||||
|
||||
static PyMethodDef reversed_methods[] = {
|
||||
{"__reversed__", (PyCFunction)reversed_reverse,
|
||||
METH_NOARGS, reversed_doc},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
static PySequenceMethods reversed_as_sequence = {
|
||||
(inquiry)reversed_len, /* sq_length */
|
||||
0, /* sq_concat */
|
||||
|
@ -289,7 +277,7 @@ PyTypeObject PyReversed_Type = {
|
|||
0, /* tp_weaklistoffset */
|
||||
PyObject_SelfIter, /* tp_iter */
|
||||
(iternextfunc)reversed_next, /* tp_iternext */
|
||||
reversed_methods, /* tp_methods */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
|
|
Loading…
Reference in New Issue