From d2c36261a202ec61bed023f22815c41d8179ace2 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 10 Mar 2004 08:32:47 +0000 Subject: Eliminate the double reverse option. It's only use case was academic and it was potentially confusing to use. --- Lib/test/test_enumerate.py | 5 +---- Objects/enumobject.c | 14 +------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py index 00ecbcc..34bc71d 100644 --- a/Lib/test/test_enumerate.py +++ b/Lib/test/test_enumerate.py @@ -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)) diff --git a/Objects/enumobject.c b/Objects/enumobject.c index 55595ce..1d13123 100644 --- a/Objects/enumobject.c +++ b/Objects/enumobject.c @@ -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 */ -- cgit v0.12