[Python-checkins] GH-100989: Revert Improve the accuracy of collections.deque docstrings (GH-102979)

miss-islington webhook-mailer at python.org
Thu Mar 23 21:17:50 EDT 2023


https://github.com/python/cpython/commit/a4a039c5465b5afe65f95db801477405886abcc9
commit: a4a039c5465b5afe65f95db801477405886abcc9
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-03-23T18:17:43-07:00
summary:

GH-100989: Revert Improve the accuracy of collections.deque docstrings (GH-102979)

(cherry picked from commit 7f01a11199864bcf230b243b99e8a51e9044675d)

Co-authored-by: Raymond Hettinger <rhettinger at users.noreply.github.com>

files:
M Modules/_collectionsmodule.c

diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index b20e51e8b0eb..741cfbe9dc61 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -916,9 +916,7 @@ deque_rotate(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
 }
 
 PyDoc_STRVAR(rotate_doc,
-"rotate(n)\n\n"
-"Rotate the deque *n* steps to the right (default ``n=1``). "
-"If *n* is negative, rotates left.");
+"Rotate the deque n steps to the right (default n=1).  If n is negative, rotates left.");
 
 static PyObject *
 deque_reverse(dequeobject *deque, PyObject *unused)
@@ -959,8 +957,7 @@ deque_reverse(dequeobject *deque, PyObject *unused)
 }
 
 PyDoc_STRVAR(reverse_doc,
-"reverse()\n\n"
-"Reverse the elements of the deque *IN PLACE*.");
+"D.reverse() -- reverse *IN PLACE*");
 
 static PyObject *
 deque_count(dequeobject *deque, PyObject *v)
@@ -1000,8 +997,7 @@ deque_count(dequeobject *deque, PyObject *v)
 }
 
 PyDoc_STRVAR(count_doc,
-"count(x) -> int\n\n"
-"Count the number of deque elements equal to *x*.");
+"D.count(value) -> integer -- return number of occurrences of value");
 
 static int
 deque_contains(dequeobject *deque, PyObject *v)
@@ -1110,10 +1106,8 @@ deque_index(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
 }
 
 PyDoc_STRVAR(index_doc,
-"index(x, [start, [stop]]) -> int\n\n"
-"Return the position of *x* in the deque "
-"(at or after index *start* and before index *stop*). "
-"Returns the first match or raises a ValueError if not found.");
+"D.index(value, [start, [stop]]) -> integer -- return first index of value.\n"
+"Raises ValueError if the value is not present.");
 
 /* insert(), remove(), and delitem() are implemented in terms of
    rotate() for simplicity and reasonable performance near the end
@@ -1158,13 +1152,10 @@ deque_insert(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
 }
 
 PyDoc_STRVAR(insert_doc,
-"insert(i, x)\n\n"
-"Insert *x* into the deque at position *i*.");
+"D.insert(index, object) -- insert object before index");
 
 PyDoc_STRVAR(remove_doc,
-"remove(x)\n\n"
-"Remove the first occurrence of *x*."
-"If not found, raises a ValueError.");
+"D.remove(value) -- remove first occurrence of value.");
 
 static int
 valid_index(Py_ssize_t i, Py_ssize_t limit)
@@ -1543,8 +1534,7 @@ deque_sizeof(dequeobject *deque, void *unused)
 }
 
 PyDoc_STRVAR(sizeof_doc,
-"__sizeof__() -> int\n\n"
-"Size of the deque in memory, in bytes.");
+"D.__sizeof__() -- size of D in memory, in bytes");
 
 static PyObject *
 deque_get_maxlen(dequeobject *deque, void *Py_UNUSED(ignored))
@@ -1579,8 +1569,7 @@ static PySequenceMethods deque_as_sequence = {
 static PyObject *deque_iter(dequeobject *deque);
 static PyObject *deque_reviter(dequeobject *deque, PyObject *Py_UNUSED(ignored));
 PyDoc_STRVAR(reversed_doc,
-"__reversed__()\n\n"
-"Return a reverse iterator over the deque.");
+    "D.__reversed__() -- return a reverse iterator over the deque");
 
 static PyMethodDef deque_methods[] = {
     {"append",                  (PyCFunction)deque_append,
@@ -1625,8 +1614,9 @@ static PyMethodDef deque_methods[] = {
 };
 
 PyDoc_STRVAR(deque_doc,
-"deque([iterable[, maxlen]]) -> collections.deque\n\n"
-"A list-like sequence optimized for data accesses near its endpoints.");
+"deque([iterable[, maxlen]]) --> deque object\n\
+\n\
+A list-like sequence optimized for data accesses near its endpoints.");
 
 static PyTypeObject deque_type = {
     PyVarObject_HEAD_INIT(NULL, 0)
@@ -2009,8 +1999,7 @@ new_defdict(defdictobject *dd, PyObject *arg)
         dd->default_factory ? dd->default_factory : Py_None, arg, NULL);
 }
 
-PyDoc_STRVAR(defdict_copy_doc, "copy() -> collections.deque\n\n"
-"A shallow copy of the deque.");
+PyDoc_STRVAR(defdict_copy_doc, "D.copy() -> a shallow copy of D.");
 
 static PyObject *
 defdict_copy(defdictobject *dd, PyObject *Py_UNUSED(ignored))



More information about the Python-checkins mailing list