mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
call_method(), call_maybe(): fix a performance bug: the argument
pointing to a static variable to hold the object form of the string was never used, causing endless calls to PyString_InternFromString(). One particular test (with lots of __getitem__ calls) became a third faster with this!
This commit is contained in:
parent
ed554f6fc7
commit
da21c0110b
1 changed files with 3 additions and 8 deletions
|
@ -378,18 +378,15 @@ call_method(PyObject *o, char *name, PyObject **nameobj, char *format, ...)
|
|||
{
|
||||
va_list va;
|
||||
PyObject *args, *func = 0, *retval;
|
||||
PyObject *dummy_str = NULL;
|
||||
va_start(va, format);
|
||||
|
||||
func = lookup_maybe(o, name, &dummy_str);
|
||||
func = lookup_maybe(o, name, nameobj);
|
||||
if (func == NULL) {
|
||||
va_end(va);
|
||||
if (!PyErr_Occurred())
|
||||
PyErr_SetObject(PyExc_AttributeError, dummy_str);
|
||||
Py_XDECREF(dummy_str);
|
||||
PyErr_SetObject(PyExc_AttributeError, *nameobj);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(dummy_str);
|
||||
|
||||
if (format && *format)
|
||||
args = Py_VaBuildValue(format, va);
|
||||
|
@ -417,11 +414,9 @@ call_maybe(PyObject *o, char *name, PyObject **nameobj, char *format, ...)
|
|||
{
|
||||
va_list va;
|
||||
PyObject *args, *func = 0, *retval;
|
||||
PyObject *dummy_str = NULL;
|
||||
va_start(va, format);
|
||||
|
||||
func = lookup_maybe(o, name, &dummy_str);
|
||||
Py_XDECREF(dummy_str);
|
||||
func = lookup_maybe(o, name, nameobj);
|
||||
if (func == NULL) {
|
||||
va_end(va);
|
||||
if (!PyErr_Occurred()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue