From: Amaury Forgeot d'Arc Date: Sat, 17 Jan 2009 17:11:50 +0000 (+0000) Subject: #4930: Slightly cleaner (and faster) code in type creation: X-Git-Tag: v2.7a1~2274 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd55c52565d171ceb78d8f3b0f8b6cc6253e8e68;p=python #4930: Slightly cleaner (and faster) code in type creation: compare slots by address, not by name. --- diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 8242242d19..5e9073d923 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6114,7 +6114,7 @@ update_one_slot(PyTypeObject *type, slotdef *p) else if (Py_TYPE(descr) == &PyCFunction_Type && PyCFunction_GET_FUNCTION(descr) == (PyCFunction)tp_new_wrapper && - strcmp(p->name, "__new__") == 0) + ptr == (void**)&type->tp_new) { /* The __new__ wrapper is not a wrapper descriptor, so must be special-cased differently. @@ -6134,7 +6134,7 @@ update_one_slot(PyTypeObject *type, slotdef *p) point out a bug in this reasoning a beer. */ } else if (descr == Py_None && - strcmp(p->name, "__hash__") == 0) { + ptr == (void**)&type->tp_hash) { /* We specifically allow __hash__ to be set to None to prevent inheritance of the default implementation from object.__hash__ */