summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-02-01 06:13:43 (GMT)
committerGitHub <noreply@github.com>2019-02-01 06:13:43 (GMT)
commit05f1b93f5876ac970485ae008dd9ab3e8404f934 (patch)
treed1fd913d8a72e0954c84146087a9199d08f7bee8 /Modules
parentffdf1c30ab6940a5efe6f33e61678021d9fd14b6 (diff)
downloadcpython-05f1b93f5876ac970485ae008dd9ab3e8404f934.zip
cpython-05f1b93f5876ac970485ae008dd9ab3e8404f934.tar.gz
cpython-05f1b93f5876ac970485ae008dd9ab3e8404f934.tar.bz2
Speed-up argument parsing for common cases in deque.__init__()(GH-11717)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_collectionsmodule.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index a2b683e..280b15d 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1463,9 +1463,13 @@ deque_init(dequeobject *deque, PyObject *args, PyObject *kwdargs)
Py_ssize_t maxlen = -1;
char *kwlist[] = {"iterable", "maxlen", 0};
- if (kwdargs == NULL) {
- if (!PyArg_UnpackTuple(args, "deque()", 0, 2, &iterable, &maxlenobj))
- return -1;
+ if (kwdargs == NULL && PyTuple_GET_SIZE(args) <= 2) {
+ if (PyTuple_GET_SIZE(args) > 0) {
+ iterable = PyTuple_GET_ITEM(args, 0);
+ }
+ if (PyTuple_GET_SIZE(args) > 1) {
+ maxlenobj = PyTuple_GET_ITEM(args, 1);
+ }
} else {
if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist,
&iterable, &maxlenobj))