Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
56bb16f1
Commit
56bb16f1
authored
Oct 11, 2003
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the simpler and faster PyArg_UnpackTuple() instead of
PyArg_ParseTuple() where possible.
parent
f34f2646
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
Objects/typeobject.c
Objects/typeobject.c
+24
-24
No files found.
Objects/typeobject.c
View file @
56bb16f1
...
@@ -3317,7 +3317,7 @@ wrap_inquiry(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3317,7 +3317,7 @@ wrap_inquiry(PyObject *self, PyObject *args, void *wrapped)
inquiry
func
=
(
inquiry
)
wrapped
;
inquiry
func
=
(
inquiry
)
wrapped
;
int
res
;
int
res
;
if
(
!
PyArg_
ParseTuple
(
args
,
""
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
0
,
0
))
return
NULL
;
return
NULL
;
res
=
(
*
func
)(
self
);
res
=
(
*
func
)(
self
);
if
(
res
==
-
1
&&
PyErr_Occurred
())
if
(
res
==
-
1
&&
PyErr_Occurred
())
...
@@ -3331,7 +3331,7 @@ wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3331,7 +3331,7 @@ wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped)
inquiry
func
=
(
inquiry
)
wrapped
;
inquiry
func
=
(
inquiry
)
wrapped
;
int
res
;
int
res
;
if
(
!
PyArg_
ParseTuple
(
args
,
""
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
0
,
0
))
return
NULL
;
return
NULL
;
res
=
(
*
func
)(
self
);
res
=
(
*
func
)(
self
);
if
(
res
==
-
1
&&
PyErr_Occurred
())
if
(
res
==
-
1
&&
PyErr_Occurred
())
...
@@ -3345,7 +3345,7 @@ wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3345,7 +3345,7 @@ wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped)
binaryfunc
func
=
(
binaryfunc
)
wrapped
;
binaryfunc
func
=
(
binaryfunc
)
wrapped
;
PyObject
*
other
;
PyObject
*
other
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
other
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
other
))
return
NULL
;
return
NULL
;
return
(
*
func
)(
self
,
other
);
return
(
*
func
)(
self
,
other
);
}
}
...
@@ -3356,7 +3356,7 @@ wrap_binaryfunc_l(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3356,7 +3356,7 @@ wrap_binaryfunc_l(PyObject *self, PyObject *args, void *wrapped)
binaryfunc
func
=
(
binaryfunc
)
wrapped
;
binaryfunc
func
=
(
binaryfunc
)
wrapped
;
PyObject
*
other
;
PyObject
*
other
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
other
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
other
))
return
NULL
;
return
NULL
;
if
(
!
(
self
->
ob_type
->
tp_flags
&
Py_TPFLAGS_CHECKTYPES
)
&&
if
(
!
(
self
->
ob_type
->
tp_flags
&
Py_TPFLAGS_CHECKTYPES
)
&&
!
PyType_IsSubtype
(
other
->
ob_type
,
self
->
ob_type
))
{
!
PyType_IsSubtype
(
other
->
ob_type
,
self
->
ob_type
))
{
...
@@ -3372,7 +3372,7 @@ wrap_binaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3372,7 +3372,7 @@ wrap_binaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
binaryfunc
func
=
(
binaryfunc
)
wrapped
;
binaryfunc
func
=
(
binaryfunc
)
wrapped
;
PyObject
*
other
;
PyObject
*
other
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
other
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
other
))
return
NULL
;
return
NULL
;
if
(
!
(
self
->
ob_type
->
tp_flags
&
Py_TPFLAGS_CHECKTYPES
)
&&
if
(
!
(
self
->
ob_type
->
tp_flags
&
Py_TPFLAGS_CHECKTYPES
)
&&
!
PyType_IsSubtype
(
other
->
ob_type
,
self
->
ob_type
))
{
!
PyType_IsSubtype
(
other
->
ob_type
,
self
->
ob_type
))
{
...
@@ -3389,7 +3389,7 @@ wrap_coercefunc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3389,7 +3389,7 @@ wrap_coercefunc(PyObject *self, PyObject *args, void *wrapped)
PyObject
*
other
,
*
res
;
PyObject
*
other
,
*
res
;
int
ok
;
int
ok
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
other
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
other
))
return
NULL
;
return
NULL
;
ok
=
func
(
&
self
,
&
other
);
ok
=
func
(
&
self
,
&
other
);
if
(
ok
<
0
)
if
(
ok
<
0
)
...
@@ -3418,7 +3418,7 @@ wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3418,7 +3418,7 @@ wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped)
/* Note: This wrapper only works for __pow__() */
/* Note: This wrapper only works for __pow__() */
if
(
!
PyArg_
ParseTuple
(
args
,
"O|O"
,
&
other
,
&
third
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
2
,
&
other
,
&
third
))
return
NULL
;
return
NULL
;
return
(
*
func
)(
self
,
other
,
third
);
return
(
*
func
)(
self
,
other
,
third
);
}
}
...
@@ -3432,7 +3432,7 @@ wrap_ternaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3432,7 +3432,7 @@ wrap_ternaryfunc_r(PyObject *self, PyObject *args, void *wrapped)
/* Note: This wrapper only works for __pow__() */
/* Note: This wrapper only works for __pow__() */
if
(
!
PyArg_
ParseTuple
(
args
,
"O|O"
,
&
other
,
&
third
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
2
,
&
other
,
&
third
))
return
NULL
;
return
NULL
;
return
(
*
func
)(
other
,
self
,
third
);
return
(
*
func
)(
other
,
self
,
third
);
}
}
...
@@ -3442,7 +3442,7 @@ wrap_unaryfunc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3442,7 +3442,7 @@ wrap_unaryfunc(PyObject *self, PyObject *args, void *wrapped)
{
{
unaryfunc
func
=
(
unaryfunc
)
wrapped
;
unaryfunc
func
=
(
unaryfunc
)
wrapped
;
if
(
!
PyArg_
ParseTuple
(
args
,
""
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
0
,
0
))
return
NULL
;
return
NULL
;
return
(
*
func
)(
self
);
return
(
*
func
)(
self
);
}
}
...
@@ -3492,7 +3492,7 @@ wrap_sq_item(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3492,7 +3492,7 @@ wrap_sq_item(PyObject *self, PyObject *args, void *wrapped)
return
NULL
;
return
NULL
;
return
(
*
func
)(
self
,
i
);
return
(
*
func
)(
self
,
i
);
}
}
PyArg_
ParseTuple
(
args
,
"O"
,
&
arg
);
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
arg
);
assert
(
PyErr_Occurred
());
assert
(
PyErr_Occurred
());
return
NULL
;
return
NULL
;
}
}
...
@@ -3515,7 +3515,7 @@ wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3515,7 +3515,7 @@ wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
int
i
,
res
;
int
i
,
res
;
PyObject
*
arg
,
*
value
;
PyObject
*
arg
,
*
value
;
if
(
!
PyArg_
ParseTuple
(
args
,
"OO"
,
&
arg
,
&
value
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
2
,
2
,
&
arg
,
&
value
))
return
NULL
;
return
NULL
;
i
=
getindex
(
self
,
arg
);
i
=
getindex
(
self
,
arg
);
if
(
i
==
-
1
&&
PyErr_Occurred
())
if
(
i
==
-
1
&&
PyErr_Occurred
())
...
@@ -3534,7 +3534,7 @@ wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3534,7 +3534,7 @@ wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped)
int
i
,
res
;
int
i
,
res
;
PyObject
*
arg
;
PyObject
*
arg
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
arg
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
arg
))
return
NULL
;
return
NULL
;
i
=
getindex
(
self
,
arg
);
i
=
getindex
(
self
,
arg
);
if
(
i
==
-
1
&&
PyErr_Occurred
())
if
(
i
==
-
1
&&
PyErr_Occurred
())
...
@@ -3585,7 +3585,7 @@ wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3585,7 +3585,7 @@ wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped)
int
res
;
int
res
;
PyObject
*
value
;
PyObject
*
value
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
value
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
value
))
return
NULL
;
return
NULL
;
res
=
(
*
func
)(
self
,
value
);
res
=
(
*
func
)(
self
,
value
);
if
(
res
==
-
1
&&
PyErr_Occurred
())
if
(
res
==
-
1
&&
PyErr_Occurred
())
...
@@ -3601,7 +3601,7 @@ wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3601,7 +3601,7 @@ wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped)
int
res
;
int
res
;
PyObject
*
key
,
*
value
;
PyObject
*
key
,
*
value
;
if
(
!
PyArg_
ParseTuple
(
args
,
"OO"
,
&
key
,
&
value
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
2
,
2
,
&
key
,
&
value
))
return
NULL
;
return
NULL
;
res
=
(
*
func
)(
self
,
key
,
value
);
res
=
(
*
func
)(
self
,
key
,
value
);
if
(
res
==
-
1
&&
PyErr_Occurred
())
if
(
res
==
-
1
&&
PyErr_Occurred
())
...
@@ -3617,7 +3617,7 @@ wrap_delitem(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3617,7 +3617,7 @@ wrap_delitem(PyObject *self, PyObject *args, void *wrapped)
int
res
;
int
res
;
PyObject
*
key
;
PyObject
*
key
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
key
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
key
))
return
NULL
;
return
NULL
;
res
=
(
*
func
)(
self
,
key
,
NULL
);
res
=
(
*
func
)(
self
,
key
,
NULL
);
if
(
res
==
-
1
&&
PyErr_Occurred
())
if
(
res
==
-
1
&&
PyErr_Occurred
())
...
@@ -3633,7 +3633,7 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3633,7 +3633,7 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped)
int
res
;
int
res
;
PyObject
*
other
;
PyObject
*
other
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
other
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
other
))
return
NULL
;
return
NULL
;
if
(
other
->
ob_type
->
tp_compare
!=
func
&&
if
(
other
->
ob_type
->
tp_compare
!=
func
&&
!
PyType_IsSubtype
(
other
->
ob_type
,
self
->
ob_type
))
{
!
PyType_IsSubtype
(
other
->
ob_type
,
self
->
ob_type
))
{
...
@@ -3676,7 +3676,7 @@ wrap_setattr(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3676,7 +3676,7 @@ wrap_setattr(PyObject *self, PyObject *args, void *wrapped)
int
res
;
int
res
;
PyObject
*
name
,
*
value
;
PyObject
*
name
,
*
value
;
if
(
!
PyArg_
ParseTuple
(
args
,
"OO"
,
&
name
,
&
value
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
2
,
2
,
&
name
,
&
value
))
return
NULL
;
return
NULL
;
if
(
!
hackcheck
(
self
,
func
,
"__setattr__"
))
if
(
!
hackcheck
(
self
,
func
,
"__setattr__"
))
return
NULL
;
return
NULL
;
...
@@ -3694,7 +3694,7 @@ wrap_delattr(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3694,7 +3694,7 @@ wrap_delattr(PyObject *self, PyObject *args, void *wrapped)
int
res
;
int
res
;
PyObject
*
name
;
PyObject
*
name
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
name
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
name
))
return
NULL
;
return
NULL
;
if
(
!
hackcheck
(
self
,
func
,
"__delattr__"
))
if
(
!
hackcheck
(
self
,
func
,
"__delattr__"
))
return
NULL
;
return
NULL
;
...
@@ -3711,7 +3711,7 @@ wrap_hashfunc(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3711,7 +3711,7 @@ wrap_hashfunc(PyObject *self, PyObject *args, void *wrapped)
hashfunc
func
=
(
hashfunc
)
wrapped
;
hashfunc
func
=
(
hashfunc
)
wrapped
;
long
res
;
long
res
;
if
(
!
PyArg_
ParseTuple
(
args
,
""
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
0
,
0
))
return
NULL
;
return
NULL
;
res
=
(
*
func
)(
self
);
res
=
(
*
func
)(
self
);
if
(
res
==
-
1
&&
PyErr_Occurred
())
if
(
res
==
-
1
&&
PyErr_Occurred
())
...
@@ -3733,7 +3733,7 @@ wrap_richcmpfunc(PyObject *self, PyObject *args, void *wrapped, int op)
...
@@ -3733,7 +3733,7 @@ wrap_richcmpfunc(PyObject *self, PyObject *args, void *wrapped, int op)
richcmpfunc
func
=
(
richcmpfunc
)
wrapped
;
richcmpfunc
func
=
(
richcmpfunc
)
wrapped
;
PyObject
*
other
;
PyObject
*
other
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
other
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
other
))
return
NULL
;
return
NULL
;
return
(
*
func
)(
self
,
other
,
op
);
return
(
*
func
)(
self
,
other
,
op
);
}
}
...
@@ -3759,7 +3759,7 @@ wrap_next(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3759,7 +3759,7 @@ wrap_next(PyObject *self, PyObject *args, void *wrapped)
unaryfunc
func
=
(
unaryfunc
)
wrapped
;
unaryfunc
func
=
(
unaryfunc
)
wrapped
;
PyObject
*
res
;
PyObject
*
res
;
if
(
!
PyArg_
ParseTuple
(
args
,
""
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
0
,
0
))
return
NULL
;
return
NULL
;
res
=
(
*
func
)(
self
);
res
=
(
*
func
)(
self
);
if
(
res
==
NULL
&&
!
PyErr_Occurred
())
if
(
res
==
NULL
&&
!
PyErr_Occurred
())
...
@@ -3774,7 +3774,7 @@ wrap_descr_get(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3774,7 +3774,7 @@ wrap_descr_get(PyObject *self, PyObject *args, void *wrapped)
PyObject
*
obj
;
PyObject
*
obj
;
PyObject
*
type
=
NULL
;
PyObject
*
type
=
NULL
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O|O"
,
&
obj
,
&
type
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
2
,
&
obj
,
&
type
))
return
NULL
;
return
NULL
;
if
(
obj
==
Py_None
)
if
(
obj
==
Py_None
)
obj
=
NULL
;
obj
=
NULL
;
...
@@ -3795,7 +3795,7 @@ wrap_descr_set(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3795,7 +3795,7 @@ wrap_descr_set(PyObject *self, PyObject *args, void *wrapped)
PyObject
*
obj
,
*
value
;
PyObject
*
obj
,
*
value
;
int
ret
;
int
ret
;
if
(
!
PyArg_
ParseTuple
(
args
,
"OO"
,
&
obj
,
&
value
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
2
,
2
,
&
obj
,
&
value
))
return
NULL
;
return
NULL
;
ret
=
(
*
func
)(
self
,
obj
,
value
);
ret
=
(
*
func
)(
self
,
obj
,
value
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -3811,7 +3811,7 @@ wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped)
...
@@ -3811,7 +3811,7 @@ wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped)
PyObject
*
obj
;
PyObject
*
obj
;
int
ret
;
int
ret
;
if
(
!
PyArg_
ParseTuple
(
args
,
"O"
,
&
obj
))
if
(
!
PyArg_
UnpackTuple
(
args
,
""
,
1
,
1
,
&
obj
))
return
NULL
;
return
NULL
;
ret
=
(
*
func
)(
self
,
obj
,
NULL
);
ret
=
(
*
func
)(
self
,
obj
,
NULL
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment