summaryrefslogtreecommitdiffstats
path: root/Modules/operator.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-12-29 16:33:45 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-12-29 16:33:45 (GMT)
commitea3fdf44a29accd666a3b5f058539c351d921657 (patch)
treeabf57eaa340195873a649d2d42d50e0dba856064 /Modules/operator.c
parentf8bcfb13f126d3990dbccecb48a3d74b11e7841e (diff)
downloadcpython-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 'Modules/operator.c')
-rw-r--r--Modules/operator.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/Modules/operator.c b/Modules/operator.c
index 55c26df..d89564d 100644
--- a/Modules/operator.c
+++ b/Modules/operator.c
@@ -12,12 +12,12 @@ used for special class methods; variants without leading and trailing\n\
#define spam1(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1; \
- if(! PyArg_ParseTuple(a,"O:" #OP,&a1)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,1,1,&a1)) return NULL; \
return AOP(a1); }
#define spam2(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1, *a2; \
- if(! PyArg_ParseTuple(a,"OO:" #OP,&a1,&a2)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
return AOP(a1,a2); }
#define spamoi(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
@@ -27,39 +27,39 @@ used for special class methods; variants without leading and trailing\n\
#define spam2n(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1, *a2; \
- if(! PyArg_ParseTuple(a,"OO:" #OP,&a1,&a2)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
if(-1 == AOP(a1,a2)) return NULL; \
Py_INCREF(Py_None); \
return Py_None; }
#define spam3n(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1, *a2, *a3; \
- if(! PyArg_ParseTuple(a,"OOO:" #OP,&a1,&a2,&a3)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,3,3,&a1,&a2,&a3)) return NULL; \
if(-1 == AOP(a1,a2,a3)) return NULL; \
Py_INCREF(Py_None); \
return Py_None; }
#define spami(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1; long r; \
- if(! PyArg_ParseTuple(a,"O:" #OP,&a1)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,1,1,&a1)) return NULL; \
if(-1 == (r=AOP(a1))) return NULL; \
return PyBool_FromLong(r); }
#define spami2(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1, *a2; long r; \
- if(! PyArg_ParseTuple(a,"OO:" #OP,&a1,&a2)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
if(-1 == (r=AOP(a1,a2))) return NULL; \
return PyInt_FromLong(r); }
#define spami2b(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1, *a2; long r; \
- if(! PyArg_ParseTuple(a,"OO:" #OP,&a1,&a2)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
if(-1 == (r=AOP(a1,a2))) return NULL; \
return PyBool_FromLong(r); }
#define spamrc(OP,A) static PyObject *OP(PyObject *s, PyObject *a) { \
PyObject *a1, *a2; \
- if(! PyArg_ParseTuple(a,"OO:" #OP,&a1,&a2)) return NULL; \
+ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
return PyObject_RichCompare(a1,a2,A); }
spami(isCallable , PyCallable_Check)
@@ -105,7 +105,7 @@ static PyObject*
op_pow(PyObject *s, PyObject *a)
{
PyObject *a1, *a2;
- if (PyArg_ParseTuple(a,"OO:pow",&a1,&a2))
+ if (PyArg_UnpackTuple(a,"pow", 2, 2, &a1, &a2))
return PyNumber_Power(a1, a2, Py_None);
return NULL;
}