mirror of
https://github.com/python/cpython.git
synced 2025-10-09 00:22:17 +00:00
Speed-up argument parsing for common cases in deque.__init__()(GH-11717)
This commit is contained in:
parent
ffdf1c30ab
commit
05f1b93f58
1 changed files with 7 additions and 3 deletions
|
@ -1463,9 +1463,13 @@ deque_init(dequeobject *deque, PyObject *args, PyObject *kwdargs)
|
||||||
Py_ssize_t maxlen = -1;
|
Py_ssize_t maxlen = -1;
|
||||||
char *kwlist[] = {"iterable", "maxlen", 0};
|
char *kwlist[] = {"iterable", "maxlen", 0};
|
||||||
|
|
||||||
if (kwdargs == NULL) {
|
if (kwdargs == NULL && PyTuple_GET_SIZE(args) <= 2) {
|
||||||
if (!PyArg_UnpackTuple(args, "deque()", 0, 2, &iterable, &maxlenobj))
|
if (PyTuple_GET_SIZE(args) > 0) {
|
||||||
return -1;
|
iterable = PyTuple_GET_ITEM(args, 0);
|
||||||
|
}
|
||||||
|
if (PyTuple_GET_SIZE(args) > 1) {
|
||||||
|
maxlenobj = PyTuple_GET_ITEM(args, 1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist,
|
||||||
&iterable, &maxlenobj))
|
&iterable, &maxlenobj))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue