8000 GH-100989: Revert Improve the accuracy of collections.deque docstring… · python/cpython@a4a039c · GitHub
[go: up one dir, main page]

Skip to content

Commit a4a039c

Browse files
GH-100989: Revert Improve the accuracy of collections.deque docstrings (GH-102979)
(cherry picked from commit 7f01a11) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
1 parent 8132aef commit a4a039c

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

Modules/_collectionsmodule.c

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,7 @@ deque_rotate(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
916916
}
917917

918918
PyDoc_STRVAR(rotate_doc,
919-
"rotate(n)\n\n"
920-
"Rotate the deque *n* steps to the right (default ``n=1``). "
921-
"If *n* is negative, rotates left.");
919+
"Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.");
922920

923921
static PyObject *
924922
deque_reverse(dequeobject *deque, PyObject *unused)
@@ -959,8 +957,7 @@ deque_reverse(dequeobject *deque, PyObject *unused)
959957
}
960958

961959
PyDoc_STRVAR(reverse_doc,
962-
"reverse()\n\n"
963-
"Reverse the elements of the deque *IN PLACE*.");
960+
"D.reverse() -- reverse *IN PLACE*");
964961

965962
static PyObject *
966963
deque_count(dequeobject *deque, PyObject *v)
@@ -1000,8 +997,7 @@ deque_count(dequeobject *deque, PyObject *v)
1000997
}
1001998

1002999
PyDoc_STRVAR(count_doc,
1003-
"count(x) -> int\n\n"
1004-
"Count the number of deque elements equal to *x*.");
1000+
"D.count(value) -> integer -- return number of occurrences of value");
10051001

10061002
static int
10071003
deque_contains(dequeobject *deque, PyObject *v)
@@ -1110,10 +1106,8 @@ deque_index(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
11101106
}
11111107

11121108
PyDoc_STRVAR(index_doc,
1113-
"index(x, [start, [stop]]) -> int\n\n"
1114-
"Return the position of *x* in the deque "
1115-
"(at or after index *start* and before index *stop*). "
1116-
"Returns the first match or raises a ValueError if not found.");
1109+
"D.index(value, [start, [stop]]) -> integer -- return first index of value.\n"
1110+
"Raises ValueError if the value is not present.");
11171111

11181112
/* insert(), remove(), and delitem() are implemented in terms of
11191113
rotate() for simplicity and reasonable performance near the end
@@ -1158,13 +1152,10 @@ deque_insert(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
11581152
}
11591153

11601154
PyDoc_STRVAR(insert_doc,
1161-
"insert(i, x)\n\n"
1162-
"Insert *x* into the deque at position *i*.");
1155+
"D.insert(index, object) -- insert object before index");
11631156

11641157
PyDoc_STRVAR(remove_doc,
1165-
"remove(x)\n\n"
1166-
"Remove the first occurrence of *x*."
1167-
"If not found, raises a ValueError.");
1158+
"D.remove(value) -- remove first occurrence of value.");
11681159

11691160
static int
11701161
valid_index(Py_ssize_t i, Py_ssize_t limit)
@@ -1543,8 +1534,7 @@ deque_sizeof(dequeobject *deque, void *unused)
15431534
}
15441535

15451536
PyDoc_STRVAR(sizeof_doc,
1546-
"__sizeof__() -> int\n\n"
1547-
"Size of the deque in memory, in bytes.");
1537+
"D.__sizeof__() -- size of D in memory, in bytes");
15481538

15491539
static PyObject *
15501540
deque_get_maxlen(dequeobject *deque, void *Py_UNUSED(ignored))
@@ -1579,8 +1569,7 @@ static PySequenceMethods deque_as_sequence = {
15791569
static PyObject *deque_iter(dequeobject *deque);
15801570
static PyObject *deque_reviter(dequeobject *deque, PyObject *Py_UNUSED(ignored));
15811571
PyDoc_STRVAR(reversed_doc,
1582-
"__reversed__()\n\n"
1583-
"Return a reverse iterator over the deque.");
1572+
"D.__reversed__() -- return a reverse iterator over the deque");
15841573

15851574
static PyMethodDef deque_methods[] = {
15861575
{"append", (PyCFunction)deque_append,
@@ -1625,8 +1614,9 @@ static PyMethodDef deque_methods[] = {
16251614
};
16261615

16271616
PyDoc_STRVAR(deque_doc,
1628-
"deque([iterable[, maxlen]]) -> collections.deque\n\n"
1629-
"A list-like sequence optimized for data accesses near its endpoints.");
1617+
"deque([iterable[, maxlen]]) --> deque object\n\
1618+
\n\
1619+
A list-like sequence optimized for data accesses near its endpoints.");
16301620

16311621
static PyTypeObject deque_type = {
16321622
PyVarObject_HEAD_INIT(NULL, 0)
@@ -2009,8 +1999,7 @@ new_defdict(defdictobject *dd, PyObject *arg)
20091999
dd->default_factory ? dd->default_factory : Py_None, arg, NULL);
20102000
}
20112001

2012-
PyDoc_STRVAR(defdict_copy_doc, "copy() -> collections.deque\n\n"
2013-
"A shallow copy of the deque.");
2002+
PyDoc_STRVAR(defdict_copy_doc, "D.copy() -> a shallow copy of D.");
20142003

20152004
static PyObject *
20162005
defdict_copy(defdictobject *dd, PyObject *Py_UNUSED(ignored))

0 commit comments

Comments
 (0)
0