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

Skip to content

Commit 206c2b1

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 77e54fe commit 206c2b1

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
@@ -920,9 +920,7 @@ deque_rotate(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
920920
}
921921

922922
PyDoc_STRVAR(rotate_doc,
923-
"rotate(n)\n\n"
924-
"Rotate the deque *n* steps to the right (default ``n=1``). "
925-
"If *n* is negative, rotates left.");
923+
"Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.");
926924

927925
static PyObject *
928926
deque_reverse(dequeobject *deque, PyObject *unused)
@@ -963,8 +961,7 @@ deque_reverse(dequeobject *deque, PyObject *unused)
963961
}
964962

965963
PyDoc_STRVAR(reverse_doc,
966-
"reverse()\n\n"
967-
"Reverse the elements of the deque *IN PLACE*.");
964+
"D.reverse() -- reverse *IN PLACE*");
968965

969966
static PyObject *
970967
deque_count(dequeobject *deque, PyObject *v)
@@ -1004,8 +1001,7 @@ deque_count(dequeobject *deque, PyObject *v)
10041001
}
10051002

10061003
PyDoc_STRVAR(count_doc,
1007-
"count(x) -> int\n\n"
1008-
"Count the number of deque elements equal to *x*.");
1004+
"D.count(value) -> integer -- return number of occurrences of value");
10091005

10101006
static int
10111007
deque_contains(dequeobject *deque, PyObject *v)
@@ -1114,10 +1110,8 @@ deque_index(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
11141110
}
11151111

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

11221116
/* insert(), remove(), and delitem() are implemented in terms of
11231117
rotate() for simplicity and reasonable performance near the end
@@ -1162,13 +1156,10 @@ deque_insert(dequeobject *deque, PyObject *const *args, Py_ssize_t nargs)
11621156
}
11631157

11641158
PyDoc_STRVAR(insert_doc,
1165-
"insert(i, x)\n\n"
1166-
"Insert *x* into the deque at position *i*.");
1159+
"D.insert(index, object) -- insert object before index");
11671160

11681161
PyDoc_STRVAR(remove_doc,
1169-
"remove(x)\n\n"
1170-
"Remove the first occurrence of *x*."
1171-
"If not found, raises a ValueError.");
1162+
"D.remove(value) -- remove first occurrence of value.");
11721163

11731164
static int
11741165
valid_index(Py_ssize_t i, Py_ssize_t limit)
@@ -1546,8 +1537,7 @@ deque_sizeof(dequeobject *deque, void *unused)
15461537
}
15471538

15481539
PyDoc_STRVAR(sizeof_doc,
1549-
"__sizeof__() -> int\n\n"
1550-
"Size of the deque in memory, in bytes.");
1540+
"D.__sizeof__() -- size of D in memory, in bytes");
15511541

15521542
static int
15531543
deque_bool(dequeobject *deque)
@@ -1602,8 +1592,7 @@ static PyNumberMethods deque_as_number = {
16021592
static PyObject *deque_iter(dequeobject *deque);
16031593
static PyObject *deque_reviter(dequeobject *deque, PyObject *Py_UNUSED(ignored));
16041594
PyDoc_STRVAR(reversed_doc,
1605-
"__reversed__()\n\n"
1606-
"Return a reverse iterator over the deque.");
1595+
"D.__reversed__() -- return a reverse iterator over the deque");
16071596

16081597
static PyMethodDef deque_methods[] = {
16091598
{"append", (PyCFunction)deque_append,
@@ -1648,8 +1637,9 @@ static PyMethodDef deque_methods[] = {
16481637
};
16491638

16501639
PyDoc_STRVAR(deque_doc,
1651-
"deque([iterable[, maxlen]]) -> collections.deque\n\n"
1652-
"A list-like sequence optimized for data accesses near its endpoints.");
1640+
"deque([iterable[, maxlen]]) --> deque object\n\
1641+
\n\
1642+
A list-like sequence optimized for data accesses near its endpoints.");
16531643

16541644
static PyTypeObject deque_type = {
16551645
PyVarObject_HEAD_INIT(NULL, 0)
@@ -2032,8 +2022,7 @@ new_defdict(defdictobject *dd, PyObject *arg)
20322022
dd->default_factory ? dd->default_factory : Py_None, arg, NULL);
20332023
}
20342024

2035-
PyDoc_STRVAR(defdict_copy_doc, "copy() -> collections.deque\n\n"
2036-
"A shallow copy of the deque.");
2025+
PyDoc_STRVAR(defdict_copy_doc, "D.copy() -> a shallow copy of D.");
20372026

20382027
static PyObject *
20392028
defdict_copy(defdictobject *dd, PyObject *Py_UNUSED(ignored))

0 commit comments

Comments
 (0)
0