diff options
author | Raymond Hettinger <python@rcn.com> | 2002-12-29 16:33:45 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2002-12-29 16:33:45 (GMT) |
commit | ea3fdf44a29accd666a3b5f058539c351d921657 (patch) | |
tree | abf57eaa340195873a649d2d42d50e0dba856064 /Objects | |
parent | f8bcfb13f126d3990dbccecb48a3d74b11e7841e (diff) | |
download | cpython-ea3fdf44a29accd666a3b5f058539c351d921657.zip cpython-ea3fdf44a29accd666a3b5f058539c351d921657.tar.gz cpython-ea3fdf44a29accd666a3b5f058539c351d921657.tar.bz2 |
SF patch #659536: Use PyArg_UnpackTuple where possible.
Obtain cleaner coding and a system wide
performance boost by using the fast, pre-parsed
PyArg_Unpack function instead of PyArg_ParseTuple
function which is driven by a format string.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/classobject.c | 2 | ||||
-rw-r--r-- | Objects/descrobject.c | 2 | ||||
-rw-r--r-- | Objects/dictobject.c | 8 | ||||
-rw-r--r-- | Objects/fileobject.c | 2 | ||||
-rw-r--r-- | Objects/funcobject.c | 4 | ||||
-rw-r--r-- | Objects/listobject.c | 2 | ||||
-rw-r--r-- | Objects/sliceobject.c | 2 | ||||
-rw-r--r-- | Objects/stringobject.c | 2 |
8 files changed, 12 insertions, 12 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index 5234a65..bc22345 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -2178,7 +2178,7 @@ instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) PyObject *self; PyObject *classObj; - if (!PyArg_ParseTuple(args, "OOO:instancemethod", + if (!PyArg_UnpackTuple(args, "instancemethod", 3, 3, &func, &self, &classObj)) return NULL; if (!PyCallable_Check(func)) { diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 761e1ab..6c78778 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -686,7 +686,7 @@ proxy_get(proxyobject *pp, PyObject *args) { PyObject *key, *def = Py_None; - if (!PyArg_ParseTuple(args, "O|O:get", &key, &def)) + if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def)) return NULL; return PyObject_CallMethod(pp->dict, "get", "(OO)", key, def); } diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 5e39dfa..de7a18e 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -972,7 +972,7 @@ dict_fromkeys(PyObject *cls, PyObject *args) PyObject *d; int status; - if (!PyArg_ParseTuple(args, "O|O:fromkeys", &seq, &value)) + if (!PyArg_UnpackTuple(args, "fromkeys", 1, 2, &seq, &value)) return NULL; d = PyObject_CallObject(cls, NULL); @@ -1479,7 +1479,7 @@ dict_get(register dictobject *mp, PyObject *args) PyObject *val = NULL; long hash; - if (!PyArg_ParseTuple(args, "O|O:get", &key, &failobj)) + if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &failobj)) return NULL; if (!PyString_CheckExact(key) || @@ -1505,7 +1505,7 @@ dict_setdefault(register dictobject *mp, PyObject *args) PyObject *val = NULL; long hash; - if (!PyArg_ParseTuple(args, "O|O:setdefault", &key, &failobj)) + if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &key, &failobj)) return NULL; if (!PyString_CheckExact(key) || @@ -1834,7 +1834,7 @@ dict_init(PyObject *self, PyObject *args, PyObject *kwds) PyObject *arg = NULL; int result = 0; - if (!PyArg_ParseTuple(args, "|O:dict", &arg)) + if (!PyArg_UnpackTuple(args, "dict", 0, 1, &arg)) result = -1; else if (arg != NULL) { diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 33fb3bc..fb73385 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -503,7 +503,7 @@ file_truncate(PyFileObject *f, PyObject *args) if (f->f_fp == NULL) return err_closed(); newsizeobj = NULL; - if (!PyArg_ParseTuple(args, "|O:truncate", &newsizeobj)) + if (!PyArg_UnpackTuple(args, "truncate", 0, 1, &newsizeobj)) return NULL; /* Set newsize to current postion if newsizeobj NULL, else to the diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 4f36df9..6154d99 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -588,7 +588,7 @@ cm_init(PyObject *self, PyObject *args, PyObject *kwds) classmethod *cm = (classmethod *)self; PyObject *callable; - if (!PyArg_ParseTuple(args, "O:classmethod", &callable)) + if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable)) return -1; Py_INCREF(callable); cm->cm_callable = callable; @@ -720,7 +720,7 @@ sm_init(PyObject *self, PyObject *args, PyObject *kwds) staticmethod *sm = (staticmethod *)self; PyObject *callable; - if (!PyArg_ParseTuple(args, "O:staticmethod", &callable)) + if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable)) return -1; Py_INCREF(callable); sm->sm_callable = callable; diff --git a/Objects/listobject.c b/Objects/listobject.c index ba47028..461350c 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1654,7 +1654,7 @@ listsort(PyListObject *self, PyObject *args) assert(self != NULL); if (args != NULL) { - if (!PyArg_ParseTuple(args, "|O:sort", &compare)) + if (!PyArg_UnpackTuple(args, "sort", 0, 1, &compare)) return NULL; } merge_init(&ms, compare); diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index 7198cca..796df2b 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -174,7 +174,7 @@ slice_new(PyTypeObject *type, PyObject *args, PyObject *kw) start = stop = step = NULL; - if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step)) + if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step)) return NULL; /* This swapping of stop and start is to maintain similarity with diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 7937b46..1e42856 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -2046,7 +2046,7 @@ string_translate(PyStringObject *self, PyObject *args) int trans_table[256]; PyObject *tableobj, *delobj = NULL; - if (!PyArg_ParseTuple(args, "O|O:translate", + if (!PyArg_UnpackTuple(args, "translate", 1, 2, &tableobj, &delobj)) return NULL; |