Skip to content

Commit ed6a4c8

Browse files
committed
Dropped PyArg_ParseTuple() calls in functions taking no arguments.
1 parent 2dc28ee commit ed6a4c8

14 files changed

+28
-72
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* Replaced PyObject_CallFunction() with *ObjArgs() where more efficient.
44

5+
* Dropped PyArg_ParseTuple() calls in functions taking no arguments.
6+
57
* psycopg/microprotocols.c: small optimizations.
68

79
2010-11-08 Daniele Varrazzo <daniele.varrazzo@gmail.com>

psycopg/adapter_asis.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ asis_str(asisObject *self)
5252
static PyObject *
5353
asis_getquoted(asisObject *self, PyObject *args)
5454
{
55-
if (!PyArg_ParseTuple(args, "")) return NULL;
5655
return asis_str(self);
5756
}
5857

@@ -84,7 +83,7 @@ static struct PyMemberDef asisObject_members[] = {
8483
/* object method table */
8584

8685
static PyMethodDef asisObject_methods[] = {
87-
{"getquoted", (PyCFunction)asis_getquoted, METH_VARARGS,
86+
{"getquoted", (PyCFunction)asis_getquoted, METH_NOARGS,
8887
"getquoted() -> wrapped object value as SQL-quoted string"},
8988
{"__conform__", (PyCFunction)asis_conform, METH_VARARGS, NULL},
9089
{NULL} /* Sentinel */

psycopg/adapter_binary.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ binary_str(binaryObject *self)
111111
static PyObject *
112112
binary_getquoted(binaryObject *self, PyObject *args)
113113
{
114-
if (!PyArg_ParseTuple(args, "")) return NULL;
115114
return binary_str(self);
116115
}
117116

@@ -162,7 +161,7 @@ static struct PyMemberDef binaryObject_members[] = {
162161
/* object method table */
163162

164163
static PyMethodDef binaryObject_methods[] = {
165-
{"getquoted", (PyCFunction)binary_getquoted, METH_VARARGS,
164+
{"getquoted", (PyCFunction)binary_getquoted, METH_NOARGS,
166165
"getquoted() -> wrapped object value as SQL-quoted binary string"},
167166
{"prepare", (PyCFunction)binary_prepare, METH_VARARGS,
168167
"prepare(conn) -> prepare for binary encoding using conn"},

psycopg/adapter_datetime.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ pydatetime_str(pydatetimeObject *self)
106106
static PyObject *
107107
pydatetime_getquoted(pydatetimeObject *self, PyObject *args)
108108
{
109-
if (!PyArg_ParseTuple(args, "")) return NULL;
110109
return pydatetime_str(self);
111110
}
112111

@@ -139,7 +138,7 @@ static struct PyMemberDef pydatetimeObject_members[] = {
139138
/* object method table */
140139

141140
static PyMethodDef pydatetimeObject_methods[] = {
142-
{"getquoted", (PyCFunction)pydatetime_getquoted, METH_VARARGS,
141+
{"getquoted", (PyCFunction)pydatetime_getquoted, METH_NOARGS,
143142
"getquoted() -> wrapped object value as SQL date/time"},
144143
{"__conform__", (PyCFunction)pydatetime_conform, METH_VARARGS, NULL},
145144
{NULL} /* Sentinel */

psycopg/adapter_list.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,14 @@ list_quote(listObject *self)
8787
}
8888

8989
static PyObject *
90-
list_str(listObject *self, PyObject *args)
90+
list_str(listObject *self)
9191
{
92-
if (!PyArg_ParseTuple(args, "")) return NULL;
9392
return list_quote(self);
9493
}
9594

9695
static PyObject *
9796
list_getquoted(listObject *self, PyObject *args)
9897
{
99-
if (!PyArg_ParseTuple(args, "")) return NULL;
10098
return list_quote(self);
10199
}
102100

@@ -148,7 +146,7 @@ static struct PyMemberDef listObject_members[] = {
148146
/* object method table */
149147

150148
static PyMethodDef listObject_methods[] = {
151-
{"getquoted", (PyCFunction)list_getquoted, METH_VARARGS,
149+
{"getquoted", (PyCFunction)list_getquoted, METH_NOARGS,
152150
"getquoted() -> wrapped object value as SQL date/time"},
153151
{"prepare", (PyCFunction)list_prepare, METH_VARARGS,
154152
"prepare(conn) -> set encoding to conn->encoding"},

psycopg/adapter_mxdatetime.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ mxdatetime_str(mxdatetimeObject *self)
106106
static PyObject *
107107
mxdatetime_getquoted(mxdatetimeObject *self, PyObject *args)
108108
{
109-
if (!PyArg_ParseTuple(args, "")) return NULL;
110109
return mxdatetime_str(self);
111110
}
112111

@@ -139,7 +138,7 @@ static struct PyMemberDef mxdatetimeObject_members[] = {
139138
/* object method table */
140139

141140
static PyMethodDef mxdatetimeObject_methods[] = {
142-
{"getquoted", (PyCFunction)mxdatetime_getquoted, METH_VARARGS,
141+
{"getquoted", (PyCFunction)mxdatetime_getquoted, METH_NOARGS,
143142
"getquoted() -> wrapped object value as SQL date/time"},
144143
{"__conform__", (PyCFunction)mxdatetime_conform, METH_VARARGS, NULL},
145144
{NULL} /* Sentinel */

psycopg/adapter_pboolean.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ pboolean_str(pbooleanObject *self)
6262
static PyObject *
6363
pboolean_getquoted(pbooleanObject *self, PyObject *args)
6464
{
65-
if (!PyArg_ParseTuple(args, "")) return NULL;
6665
return pboolean_str(self);
6766
}
6867

@@ -94,7 +93,7 @@ static struct PyMemberDef pbooleanObject_members[] = {
9493
/* object method table */
9594

9695
static PyMethodDef pbooleanObject_methods[] = {
97-
{"getquoted", (PyCFunction)pboolean_getquoted, METH_VARARGS,
96+
{"getquoted", (PyCFunction)pboolean_getquoted, METH_NOARGS,
9897
"getquoted() -> wrapped object value as SQL-quoted string"},
9998
{"__conform__", (PyCFunction)pboolean_conform, METH_VARARGS, NULL},
10099
{NULL} /* Sentinel */

psycopg/adapter_pdecimal.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ pdecimal_str(pdecimalObject *self)
8484
static PyObject *
8585
pdecimal_getquoted(pdecimalObject *self, PyObject *args)
8686
{
87-
if (!PyArg_ParseTuple(args, "")) return NULL;
8887
return pdecimal_str(self);
8988
}
9089

@@ -116,7 +115,7 @@ static struct PyMemberDef pdecimalObject_members[] = {
116115
/* object method table */
117116

118117
static PyMethodDef pdecimalObject_methods[] = {
119-
{"getquoted", (PyCFunction)pdecimal_getquoted, METH_VARARGS,
118+
{"getquoted", (PyCFunction)pdecimal_getquoted, METH_NOARGS,
120119
"getquoted() -> wrapped object value as SQL-quoted string"},
121120
{"__conform__", (PyCFunction)pdecimal_conform, METH_VARARGS, NULL},
122121
{NULL} /* Sentinel */

psycopg/adapter_pfloat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pfloat_str(pfloatObject *self)
5454
static PyObject *
5555
pfloat_getquoted(pfloatObject *self, PyObject *args)
5656
{
57-
if (!PyArg_ParseTuple(args, "")) return NULL;
5857
return pfloat_str(self);
5958
}
6059

@@ -86,7 +85,7 @@ static struct PyMemberDef pfloatObject_members[] = {
8685
/* object method table */
8786

8887
static PyMethodDef pfloatObject_methods[] = {
89-
{"getquoted", (PyCFunction)pfloat_getquoted, METH_VARARGS,
88+
{"getquoted", (PyCFunction)pfloat_getquoted, METH_NOARGS,
9089
"getquoted() -> wrapped object value as SQL-quoted string"},
9190
{"__conform__", (PyCFunction)pfloat_conform, METH_VARARGS, NULL},
9291
{NULL} /* Sentinel */

psycopg/adapter_qstring.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ qstring_str(qstringObject *self)
136136
static PyObject *
137137
qstring_getquoted(qstringObject *self, PyObject *args)
138138
{
139-
if (!PyArg_ParseTuple(args, "")) return NULL;
140139
return qstring_str(self);
141140
}
142141

@@ -196,7 +195,7 @@ static struct PyMemberDef qstringObject_members[] = {
196195
/* object method table */
197196

198197
static PyMethodDef qstringObject_methods[] = {
199-
{"getquoted", (PyCFunction)qstring_getquoted, METH_VARARGS,
198+
{"getquoted", (PyCFunction)qstring_getquoted, METH_NOARGS,
200199
"getquoted() -> wrapped object value as SQL-quoted string"},
201200
{"prepare", (PyCFunction)qstring_prepare, METH_VARARGS,
202201
"prepare(conn) -> set encoding to conn->encoding and store conn"},

0 commit comments

Comments
 (0)