[Python-checkins] cpython: Avoid call_function_tail() for empty format str
victor.stinner
python-checkins at python.org
Fri Aug 19 11:32:22 EDT 2016
https://hg.python.org/cpython/rev/5cf9524f2923
changeset: 102762:5cf9524f2923
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Aug 19 17:04:54 2016 +0200
summary:
Avoid call_function_tail() for empty format str
Issue #27128, PyObject_CallFunction(), _PyObject_FastCall() and callmethod():
if the format string of parameters is empty, avoid the creation of an empty
tuple: call _PyObject_FastCall() without parameters.
files:
Objects/abstract.c | 39 ++++++++++++++++-----------------
1 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2324,14 +2324,13 @@
return null_error();
}
- if (format && *format) {
- va_start(va, format);
- args = Py_VaBuildValue(format, va);
- va_end(va);
+ if (!format || !*format) {
+ return _PyObject_FastCall(callable, NULL, 0, NULL);
}
- else {
- args = PyTuple_New(0);
- }
+
+ va_start(va, format);
+ args = Py_VaBuildValue(format, va);
+ va_end(va);
if (args == NULL) {
return NULL;
}
@@ -2351,14 +2350,13 @@
return null_error();
}
- if (format && *format) {
- va_start(va, format);
- args = _Py_VaBuildValue_SizeT(format, va);
- va_end(va);
+ if (!format || !*format) {
+ return _PyObject_FastCall(callable, NULL, 0, NULL);
}
- else {
- args = PyTuple_New(0);
- }
+
+ va_start(va, format);
+ args = _Py_VaBuildValue_SizeT(format, va);
+ va_end(va);
if (args == NULL) {
return NULL;
}
@@ -2380,14 +2378,15 @@
return NULL;
}
- if (format && *format) {
- if (is_size_t)
- args = _Py_VaBuildValue_SizeT(format, va);
- else
- args = Py_VaBuildValue(format, va);
+ if (!format || !*format) {
+ return _PyObject_FastCall(func, NULL, 0, NULL);
+ }
+
+ if (is_size_t) {
+ args = _Py_VaBuildValue_SizeT(format, va);
}
else {
- args = PyTuple_New(0);
+ args = Py_VaBuildValue(format, va);
}
if (args == NULL) {
return NULL;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list